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

41 lines
1.4 KiB
TypeScript

// Metro module 9066 (f9067).
import { useMemo } from "react";
import GameStore from "../../games/GameStore";
import UserStore from "../../../stores/UserStore";
import { GAME_MENTION_RAW_RE_GLOBAL, extractGameMentionIds } from "../../channel_autocomplete/ChannelAutocompleteConstants";
import { useGames } from "../../games/hooks/useGame";
import { useStateFromStores } from "../../../_bundle/Module589";
import { isNullOrEmpty } from "../../../utils/StringUtils";
import { isGameProfileObscured } from "../../game_profile/hooks/useGameProfileObscured";
import { intl, t } from "../../../intl/index.native";
export function useGameMentionsAsPlainText(a0) {
let c16937_0 = a0;
const memo = useMemo(() => {
let r4 = c16937_0;
if (r4 == null) {
r4 = "";
}
return extractGameMentionIds(r4);
}, [a0]);
useGames(memo);
return useStateFromStores([GameStore, UserStore], () => {
if (!isNullOrEmpty(c16937_0) && memo.length !== 0) {
const nsfwAllowed = UserStore.getCurrentUser()?.nsfwAllowed;
return c16937_0.replace(GAME_MENTION_RAW_RE_GLOBAL, (a0, a1) => {
let r16;
const game = GameStore.getGame(a1);
if (isGameProfileObscured(game, nsfwAllowed)) {
r16 = intl.string(t["11pdXZ"]);
} else {
r16 = game?.name;
if (r16 == null) {
r16 = intl.string(t["11pdXZ"]);
}
}
return r16;
});
}
return c16937_0;
}, [a0, memo]);
}