121 lines
3.3 KiB
TypeScript
121 lines
3.3 KiB
TypeScript
// Metro module 11951 (f11952).
|
|
import { useMemo } from "react";
|
|
import "../../games/GameRecord";
|
|
import GameStore from "../../games/GameStore";
|
|
import AuthenticationStore from "../../../stores/AuthenticationStore";
|
|
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/Module589";
|
|
import { useGames } from "../../games/hooks/useGame";
|
|
function $mk88474($env) {
|
|
return () => {
|
|
const r1 = $env;
|
|
const r7 = r1[0].gameApplicationIds.map($mk108552(r1));
|
|
const r9 = $env.$parent;
|
|
return r7.filter((0, r9[0])(r9[1][6]).isNotNullish);
|
|
};
|
|
}
|
|
function $mk108551($env) {
|
|
return () => {
|
|
let r21;
|
|
const map = new Map();
|
|
const r26 = $env[0];
|
|
if (r26 == null) {
|
|
return map;
|
|
}
|
|
let r27 = r26[Symbol.iterator]();
|
|
const next = r27.next;
|
|
const r3 = $env.$parent;
|
|
while (true) {
|
|
const r9 = r27 === void 0 ? void 0 : (r21 = next.call(r27)).done ? r27 = void 0 : r21.value;
|
|
if (r27 === void 0) {
|
|
return map;
|
|
}
|
|
try {
|
|
map.set(r9.id, new r3[3](r9));
|
|
} catch (r36) {
|
|
if (r27 !== void 0 && typeof r27.return === "function") {
|
|
try {
|
|
r27.return();
|
|
} catch {}
|
|
}
|
|
throw r36;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
function $mk108552($env) {
|
|
return (a0) => {
|
|
let r6 = $env.$parent[4].getGame(a0);
|
|
if (r6 == null) {
|
|
r6 = $env[1].get(a0);
|
|
}
|
|
return r6;
|
|
};
|
|
}
|
|
let $mk88473 = function() {
|
|
return () => AuthenticationStore.isAuthenticated();
|
|
};
|
|
let env8195 = {};
|
|
export default function useGuildProfileGames(a0) {
|
|
let env19285;
|
|
const gameActivity = a0.gameActivity;
|
|
const r4 = env19285 = {
|
|
$parent: env8195
|
|
};
|
|
env19285[0] = a0;
|
|
env19285[1] = void 0;
|
|
const games = a0.games;
|
|
const stateFromStores = useStateFromStores([AuthenticationStore], $mk88473());
|
|
const r20 = games != null && !stateFromStores ? [] : a0.gameApplicationIds;
|
|
let env19286;
|
|
useGames(r20);
|
|
const r22 = env19286 = {
|
|
$parent: env8195
|
|
};
|
|
env19286[0] = games;
|
|
env19285[1] = useMemo($mk108551(r22), [games]);
|
|
const stateFromStoresArray = useStateFromStoresArray([GameStore], $mk88474(r4));
|
|
const memo = useMemo(() => {
|
|
const gameActivity2 = gameActivity;
|
|
return [...stateFromStoresArray].sort((a, b) => {
|
|
let r4 = gameActivity2[a.id]?.score;
|
|
if (r4 == null) {
|
|
r4 = 0;
|
|
}
|
|
let r5 = gameActivity2[b.id]?.score;
|
|
if (r5 == null) {
|
|
r5 = 0;
|
|
}
|
|
return r4 !== r5 ? r5 - r4 : 0;
|
|
});
|
|
}, [stateFromStoresArray, gameActivity]);
|
|
return {
|
|
gamesToDisplay: useMemo(() => memo.slice(0, 5), [memo]),
|
|
lastGameToDisplay: useMemo(() => {
|
|
let r3 = memo[5];
|
|
if (r3 == null) {
|
|
r3 = null;
|
|
}
|
|
return r3;
|
|
}, [memo]),
|
|
remainingGames: useMemo(() => memo.slice(5), [memo])
|
|
};
|
|
};
|
|
export function useAllGuildProfileGames(a0) {
|
|
let env19282;
|
|
const r2 = env19282 = {
|
|
$parent: env8195
|
|
};
|
|
env19282[0] = a0;
|
|
const games = a0.games;
|
|
const stateFromStores = useStateFromStores([AuthenticationStore], $mk88473());
|
|
const r18 = games != null && !stateFromStores ? [] : a0.gameApplicationIds;
|
|
let env19283;
|
|
useGames(r18);
|
|
const r20 = env19283 = {
|
|
$parent: env8195
|
|
};
|
|
env19283[0] = games;
|
|
env19282[1] = useMemo($mk108551(r20), [games]);
|
|
return useStateFromStoresArray([GameStore], $mk88474(r2));
|
|
}
|