// Metro module 8656 (f8657). import LocaleStore from "../user_settings/LocaleStore"; import GameProfileStore from "./GameProfileStore"; import { Endpoints } from "../../Constants"; import { SIMILAR_GAMES_BLOCKED_GAME_IDS } from "../../_bundle/Module8657"; import Dispatcher from "../../Dispatcher"; import { httpGetWithCountryCodeQuery } from "../../utils/StoreUtils"; import { HTTP } from "../../_bundle/sendRequest"; import { createFetchStore } from "../../_bundle/Module589"; import Backoff from "../../_bundle/Backoff"; import Durations from "../../utils/Durations"; import { toAnnouncementMessages } from "./AnnouncementMessageUtils"; function $mk115326($env) { return (a0) => a0 !== $env[0] && !SIMILAR_GAMES_BLOCKED_GAME_IDS.has(a0); } let env5633 = {}; env5633[9] = function _fetchSimilarGames() { const r8 = async (c26255_0) => { let env29959; const r11 = env5633; let c26255_3 = r11; const r23 = env29959 = { $parent: r11 }; let c26255_2 = r23; env29959[0] = c26255_0; env29959[1] = void 0; const similar_games2 = (await HTTP.get({ url: Endpoints.SIMILAR_GAMES(c26255_0), rejectWithError: true })).body.similar_games; let similar_games = similar_games2; if (similar_games2 == null) { similar_games = []; } env29959[1] = similar_games.filter($mk115326(c26255_2)); Dispatcher.dispatch({ type: "GAME_PROFILE_GET_SIMILAR_GAMES_SUCCESS", gameId: env29959[0], games: env29959[1] }); }; env5633[9] = r8; return r8.apply(this, arguments); }; const fetchStore = createFetchStore(GameProfileStore, { getQueryId: (a0, a1) => a1 ? `similar-games:${a0}` : null, get: (a0) => { let r5 = GameProfileStore.getSimilarGames(a0); if (r5 == null) { r5 = null; } return r5; }, load: (a0) => (function fetchSimilarGames() { return env5633[9].apply(this, arguments); })(a0), retryConfig: { backoff: () => new Backoff(5 * Durations.Millis.SECOND, 5 * Durations.Millis.MINUTE) }, failureStaleAfter: Durations.Seconds.MINUTE }); export async function getShopCollection(collectionId) { let c26254_1, c26254_2, c26254_3; let c26254_4 = 0; const r11 = env5633; L10: { try { let env29958; c26254_2 = r11; const r27 = env29958 = {}; c26254_1 = r27; env29958[0] = collectionId; env29958[1] = void 0; Dispatcher.dispatch({ type: "GAME_PROFILE_GET_SHOP_COLLECTION_START", collectionId }); c26254_4 = 1; env29958[1] = (await httpGetWithCountryCodeQuery({ url: Endpoints.STOREFRONT_COLLECTION_WITH_PRODUCTS(collectionId), query: { locale: LocaleStore.locale }, rejectWithError: false, retries: 2 })).body.products.flatMap((product) => product.sku_ids); Dispatcher.dispatch({ type: "GAME_PROFILE_GET_SHOP_COLLECTION_SUCCESS", collectionId: env29958[0], skuIds: env29958[1] }); c26254_4 = 0; } catch ($e) { const r25 = $e; let r8 = r25; c26254_3 = r25; if (c26254_4 !== 0) { while (true) { try { c26254_4 = 0; Dispatcher.dispatch({ type: "GAME_PROFILE_GET_SHOP_COLLECTION_ERROR", collectionId: env29958[0] }); break L10; } catch (r79) { r8 = r79; c26254_3 = r79; if (c26254_4 === 0) { break; } } } } throw r8; } } } export { fetchStore as useSimilarGameIds }; export async function getGameAnnouncements(gameId, c26256_1) { let channel_id, guild_id; let c26256_7 = 0; let c29960_0, c29960_1; L18: { try { c29960_0 = gameId; c29960_1 = void 0; Dispatcher.dispatch({ type: "GAME_PROFILE_GET_ANNOUNCEMENTS_START", gameId }); c26256_7 = 1; const limit = c26256_1?.limit; const query = {}; if (limit != null) { query.limit = c26256_1.limit; } c29960_1 = (await HTTP.get({ url: Endpoints.GAME_ANNOUNCEMENTS(gameId), query, rejectWithError: false })).body; const r73 = { type: "GAME_PROFILE_GET_ANNOUNCEMENTS_SUCCESS", gameId: c29960_0, messages: toAnnouncementMessages(c29960_1.messages), channelId: null, guildId: null }; channel_id = c29960_1.channel_id; if (channel_id == null) { channel_id = void 0; } r73.channelId = channel_id; guild_id = c29960_1.guild_id; if (guild_id == null) { guild_id = void 0; } r73.guildId = guild_id; Dispatcher.dispatch(r73); c26256_7 = 0; } catch ($e) { let r8 = $e; if (c26256_7 !== 0) { while (true) { try { c26256_7 = 0; Dispatcher.dispatch({ type: "GAME_PROFILE_GET_ANNOUNCEMENTS_ERROR", gameId: c29960_0 }); break L18; } catch ($e) { r8 = $e; if (c26256_7 === 0) { break; } } } } throw r8; } } }