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

21 lines
1006 B
TypeScript

// Metro module 9878 (f9879).
import { useState, useEffect } from "react";
import ChannelFollowerStatsStore from "../../stores/ChannelFollowerStatsStore";
import Durations from "../../utils/Durations";
import { useStateFromStores } from "../../_bundle/Module589";
import ChannelFollowerActionCreators from "../../actions/ChannelFollowerActionCreators";
let c6549_6 = 1 * Durations.Millis.HOUR;
export default function useChannelFollowerStats(a0) {
const [state, setState] = useState(false);
const stateFromStores = useStateFromStores([ChannelFollowerStatsStore], () => ChannelFollowerStatsStore.getFollowerStatsForChannel(a0), [a0]);
useEffect(() => {
if (!(stateFromStores != null && !(Date.now() - stateFromStores.lastFetched > c6549_6)) && !state) {
setState(true);
ChannelFollowerActionCreators.fetchChannelFollowerStats(a0);
} else if (stateFromStores != null && state) {
setState(false);
}
}, [a0, stateFromStores, state]);
return [stateFromStores, state];
};