// Metro module 5903 (f5904). import UserStore from "../../stores/UserStore"; import { Endpoints } from "../../Constants"; import Dispatcher from "../../Dispatcher"; import { HTTP } from "../../_bundle/sendRequest"; import SentryUtils_native from "../../utils/SentryUtils.native"; const r20 = { setPendingWidgets: (a0) => { Dispatcher.dispatch({ type: "WIDGET_PENDING_SET", widgets: a0 }); }, savePendingWidgets: async (c15259_0) => { let body; let c25639_0, c25639_1, c25639_2; let c25639_3 = 0; const r11 = void 0; L14: { try { let env29631; c25639_1 = r11; const r16 = env29631 = {}; c25639_0 = r16; env29631[0] = void 0; env29631[1] = void 0; const id = UserStore.getCurrentUser()?.id; env29631[0] = id; if (id != null) { Dispatcher.dispatch({ type: "WIDGET_PENDING_SAVE_START" }); const widgets = c15259_0.map((item) => item.toSubmission()); c25639_3 = 1; env29631[1] = await HTTP.put({ url: Endpoints.USER_PROFILE_WIDGETS, body: { widgets }, oldFormErrors: true, rejectWithError: true }); Dispatcher.dispatch({ type: "WIDGET_PENDING_SAVE_SUCCESS", userId: env29631[0], widgets: env29631[1].body.widgets }); body = env29631[1].body; c25639_3 = 0; break L14; } } catch ($e) { const r26 = $e; let r8 = r26; c25639_2 = r26; if (c25639_3 !== 0) { while (true) { try { const r94 = c25639_2; c25639_3 = 0; env29631[2] = r94; Dispatcher.dispatch({ type: "WIDGET_PENDING_SAVE_FAILURE" }); throw env29631[2]; } catch (r90) { r8 = r90; c25639_2 = r90; if (c25639_3 === 0) { break; } } } } throw r8; } return void 0; } return body; }, clearPendingWidgets: () => { Dispatcher.dispatch({ type: "WIDGET_PENDING_CLEAR" }); }, uploadWidgetAsset: async (c15260_0) => { let c25640_1; c25640_1 = void 0; let c29632_0 = (await HTTP.post({ url: Endpoints.USER_PROFILE_WIDGET_ASSET_UPLOAD, body: { filename: c15260_0.name, file_size: c15260_0.size }, rejectWithError: true })).body; let c29632_1 = c29632_0.upload_url; let c29632_2 = c29632_0.upload_filename; let c29632_3 = await fetch(c29632_1, { method: "PUT", body: c15260_0, headers: { "Content-Type": c15260_0.type !== "" ? c15260_0.type : "application/octet-stream" } }); if (!c29632_3.ok) { throw new Error(`Failed to upload widget asset: ${c29632_3.status}`); } return c29632_2; }, fetchSuggestedGames: async () => { let suggested_games, suggested_wishlist_games, c25641_4; let c25641_5 = 0; let c29633_0, c29633_1; try { c29633_0 = void 0; Dispatcher.dispatch({ type: "WIDGET_SUGGESTED_FETCH_START" }); c25641_5 = 1; c29633_0 = await HTTP.get({ url: Endpoints.USER_PROFILE_SUGGESTED_GAMES, rejectWithError: true }); if (!(c29633_0.body?.suggested_games != null && c29633_0.body?.suggested_wishlist_games != null)) { SentryUtils_native.captureMessage("Suggested games or wishlist games not found"); } const suggested_games2 = c29633_0.body?.suggested_games; suggested_games = suggested_games2; if (suggested_games2 == null) { suggested_games = []; } const suggested_wishlist_games2 = c29633_0.body?.suggested_wishlist_games; suggested_wishlist_games = suggested_wishlist_games2; if (suggested_wishlist_games2 == null) { suggested_wishlist_games = []; } Dispatcher.dispatch({ type: "WIDGET_SUGGESTED_FETCH_SUCCESS", suggestedGamesIds: suggested_games, suggestedWishlistGamesIds: suggested_wishlist_games }); c25641_5 = 0; } catch ($e) { const r27 = $e; let r8 = r27; c25641_4 = r27; if (c25641_5 !== 0) { while (true) { try { const r107 = c25641_4; c25641_5 = 0; c29633_1 = r107; Dispatcher.dispatch({ type: "WIDGET_SUGGESTED_FETCH_FAILURE" }); SentryUtils_native.captureException(c29633_1); throw c29633_1; } catch (r103) { r8 = r103; c25641_4 = r103; if (c25641_5 === 0) { break; } } } } throw r8; } }, removeGameFromSuggestedGames: (a0) => { Dispatcher.dispatch({ type: "WIDGET_SUGGESTED_REMOVE_GAME", applicationId: a0 }); } }; export default r20;