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

83 lines
2.1 KiB
TypeScript

// Metro module 4210 (f4211).
import GameRecord from "./GameRecord";
import Module589 from "../../_bundle/Module589";
import URLUtils from "../../utils/URLUtils";
import Dispatcher from "../../Dispatcher";
let c2430_3 = new Map();
let c2430_4 = new Set();
let c2430_5 = new Set();
let c2430_6 = new Set();
class GameStore extends Module589.Store {
static displayName = "NewGameStore";
isFetching(a0) {
return c2430_4.has(a0);
}
didFetchingFail(a0) {
return c2430_5.has(a0);
}
getGame(a0) {
return c2430_3.get(a0);
}
hasNoData(a0) {
return c2430_6.has(a0);
}
getCoverImageUrl(a0, a1) {
const r10 = c2430_3.get(a0);
const r11 = r10 == null ? void 0 : r10.getCoverURL();
if (r11 == null) {
return null;
}
if (a1 == null) {
return r11;
}
const r19 = URLUtils.toURLSafe(r11);
let r20 = r11;
if (r19 != null) {
r19.searchParams.set("size", a1.size.toString());
r20 = r19.toString();
}
return r20;
}
}
const gameStore = new GameStore(Dispatcher, {
LOGOUT: function handleLogout() {
c2430_3 = new Map();
c2430_4 = new Set();
c2430_5 = new Set();
c2430_6 = new Set();
},
GAME_FETCH: function handleFetch(a0) {
a0.gameIds.forEach((gameId) => {
c2430_4.add(gameId);
c2430_5.delete(gameId);
});
},
GAME_FETCH_CANCELLED: function handleFetchCancelled(a0) {
a0.gameIds.forEach((gameId) => c2430_4.delete(gameId));
},
GAME_FETCH_SUCCESS: function handleFetchSuccess({ gameIds, games }) {
const set = new Set(gameIds);
let c13988_0 = set;
gameIds.forEach((gameId) => {
c2430_4.delete(gameId);
c2430_5.delete(gameId);
});
games.forEach((game) => {
c13988_0.delete(game.id);
c2430_3.set(game.id, new GameRecord(game));
});
set.forEach((item) => {
if (!c2430_3.has(item)) {
c2430_6.add(item);
}
});
},
GAME_FETCH_FAILURE: function handleFetchFailure(a0) {
a0.gameIds.forEach((gameId) => {
c2430_4.delete(gameId);
c2430_5.add(gameId);
});
}
});
export default gameStore;