Files
discord-decomp/modules/games/hooks/useGame.tsx
T
2026-11-01 12:12:55 +02:00

56 lines
1.6 KiB
TypeScript

// Metro module 5906 (f5907).
import { useEffect } from "react";
import GameStore from "../GameStore";
import { QueryIds } from "../../../Constants";
import * as _Module589 from "../../../_bundle/Module589";
import { createFetchStore } from "../../../_bundle/Module589";
import Durations from "../../../utils/Durations";
import { fetchGamesWithSupplementalData } from "../GameActionCreators";
let c3698_2, fetchStore;
const r27 = {
getQueryId: QueryIds.GAME,
failureStaleAfter: 15 * Durations.Seconds.SECOND,
get: (a0) => {
let NO_DATA;
const r1 = a0 == null;
let r2 = null;
if (!r1) {
if (GameStore.hasNoData(a0)) {
NO_DATA = _Module589.NO_DATA;
} else {
NO_DATA = GameStore.getGame(a0);
if (NO_DATA == null) {
NO_DATA = null;
}
}
r2 = NO_DATA;
}
return r2;
},
load: null,
getIsLoading: null,
getError: null
};
c3698_2 = async (c15261_0) => {
L11: {
if (c15261_0 != null) {
await fetchGamesWithSupplementalData([c15261_0]);
break L11;
}
return void 0;
}
};
r27.load = function() {
const apply = c3698_2.apply;
return c3698_2.apply(this, arguments);
};
r27.getIsLoading = (a0) => a0 != null && GameStore.isFetching(a0);
r27.getError = (a0) => a0 != null ? GameStore.didFetchingFail(a0) ? new Error("Failed to fetch game data") : null : null;
fetchStore = createFetchStore(GameStore, r27);
export { fetchStore as useGame };
export function useGames(a0) {
useEffect(() => {
fetchStore.fetchMany.apply(fetchStore, [...a0.map((item) => [item])]);
}, [a0]);
}