Files
discord-decomp/modules/guild_communication_disabled/useCommunicationDisabledCountdownCleanup.tsx
T
2026-11-01 12:12:55 +02:00

29 lines
1.1 KiB
TypeScript

// Metro module 11554 (f11555).
import { useEffect, useRef } from "react";
import useCountdown from "../../hooks/useCountdown";
import CommunicationDisabledManager from "./CommunicationDisabledManager";
export function useCommunicationDisabledCountdownCleanup(a0) {
const r2 = a0 == null ? {} : a0;
const { communicationDisabledUntil, userId, guildId } = r2;
const countdown = useCountdown(communicationDisabledUntil != null ? Date.parse(communicationDisabledUntil) : Date.now());
const seconds = countdown.seconds;
const ref = useRef(null);
useEffect(() => {
if (a0 != null && guildId != null && userId != null) {
if (seconds <= 0 && ref.current == null) {
ref.current = setTimeout(() => {
CommunicationDisabledManager.clearGuildMemberTimeout(guildId, userId);
}, 1000);
}
return () => {
if (ref.current != null) {
clearTimeout(ref.current);
ref.current = null;
}
};
}
clearTimeout(ref.current);
}, [guildId, userId, seconds, communicationDisabledUntil, a0]);
return countdown;
}