Files
discord-decomp/lib/MuteTimers.tsx
T
2026-11-01 12:12:55 +02:00

41 lines
1.1 KiB
TypeScript

// Metro module 3820 (f3821).
class MuteTimers {
timers = {};
reset() {
Object.values(this.timers).forEach((item) => clearTimeout(item));
this.timers = {};
}
setTimer(a0, a1, a2) {
if (a0 == null) {
return false;
}
if (a1 == null) {
return false;
}
const r10 = a1.end_time == null ? null : new Date(a1.end_time).getTime() - Date.now();
let r22 = r10 != null;
if (r22) {
let r23 = r10 <= 0;
if (!r23) {
this.timers[a0] = setTimeout(a2, Math.max(0, r10));
r23 = false;
}
r22 = r23;
}
return r22;
}
clearTimer(a0) {
if (a0 != null && a0 in this.timers) {
clearTimeout(this.timers[a0]);
delete this.timers[a0];
}
}
}
export default MuteTimers;
export function computeIsMuted({ muted, mute_config }) {
return !!muted && (mute_config == null || mute_config.end_time == null || new Date(mute_config.end_time) >= new Date());
}
export function isTemporarilyMuted({ muted, mute_config }) {
return !!muted && mute_config != null && mute_config.end_time != null && new Date(mute_config.end_time) >= new Date();
}