35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
// Metro module 8655 (f8656).
|
|
import { useEffect } from "react";
|
|
import GameProfileStore from "../GameProfileStore";
|
|
import { useStateFromStoresObject } from "../../../_bundle/Module589";
|
|
import { getGameAnnouncements } from "../GameProfileHttpUtils";
|
|
export default function useGameAnnouncements(a0, a1) {
|
|
let hasFetched;
|
|
const limit = a1;
|
|
const stateFromStoresObject = useStateFromStoresObject([GameProfileStore], () => ({
|
|
data: a0 != null ? GameProfileStore.getAnnouncements(a0) : void 0,
|
|
hasFetched: a0 != null && GameProfileStore.hasAnnouncementsBeenFetched(a0),
|
|
isFetching: a0 != null && GameProfileStore.isAnnouncementsFetching(a0)
|
|
}));
|
|
const data = stateFromStoresObject.data;
|
|
hasFetched = stateFromStoresObject.hasFetched;
|
|
const isFetching = stateFromStoresObject.isFetching;
|
|
useEffect(() => {
|
|
if (!(a0 == null || hasFetched || GameProfileStore.isAnnouncementsFetching(a0))) {
|
|
getGameAnnouncements(a0, {
|
|
limit
|
|
});
|
|
}
|
|
}, [a0, hasFetched, a1]);
|
|
let messages = data?.messages;
|
|
if (messages == null) {
|
|
messages = [];
|
|
}
|
|
return {
|
|
messages,
|
|
channelId: data?.channelId,
|
|
guildId: data?.guildId,
|
|
loading: isFetching
|
|
};
|
|
};
|