845 lines
24 KiB
TypeScript
845 lines
24 KiB
TypeScript
// Metro module 5797 (f5798).
|
|
import DevSettingsStore from "../devtools/dev_settings/DevSettingsStore";
|
|
import LocaleStore from "../user_settings/LocaleStore";
|
|
import CollectiblesCategoryStore from "./CollectiblesCategoryStore";
|
|
import { addDebugLog } from "./CollectiblesDebugStore";
|
|
import CollectiblesPurchaseStore from "./CollectiblesPurchaseStore";
|
|
import CollectiblesShopStore from "./CollectiblesShopStore";
|
|
import { CollectiblesCategoriesRecord } from "./records/CollectiblesCategoriesRecord";
|
|
import { CollectiblesMarketingsRecord } from "./records/CollectiblesMarketingRecord";
|
|
import CollectiblesProductRecord from "./records/CollectiblesProductRecord";
|
|
import CollectiblesPurchaseRecord from "./records/CollectiblesPurchaseRecord";
|
|
import { CollectiblesShopHomeRecord } from "./records/CollectiblesShopHomeRecord";
|
|
import { CollectiblesMobileShopScreen } from "./CollectiblesShopConstants";
|
|
import { Endpoints, UserSettingsSections, Routes } from "../../Constants";
|
|
import "./CollectiblesMarketingsStore";
|
|
import "./CollectiblesShopHomeStore";
|
|
import { getRootNavigationRef } from "../main_tabs_v2/RootNavigationRef.native";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import { popLayer } from "../../actions/LayerActionCreators";
|
|
import { buildFetchCollectiblesOptionsQuery } from "./utils/CollectiblesUtils";
|
|
import { trackShopPerf, CollectiblesShopPerfCheckpoint } from "./utils/CollectiblesPerfLogging";
|
|
import { HTTP } from "../../_bundle/sendRequest";
|
|
import { APIError } from "../../errors/index";
|
|
import { captureOrIgnoreApiError } from "../errors/ErrorHandlingUtils";
|
|
import { ShopVariantsReturnStyle } from "../../_bundle/Module5847";
|
|
import { extendVariantsProducts } from "./CollectiblesUtils";
|
|
import { CollectiblesMarketingReleaseType } from "../../_bundle/Module5853";
|
|
import { CollectiblesMarketingPlatform } from "../../_bundle/Module5854";
|
|
let openCollectiblesShopMobile, fetchCollectiblesProduct;
|
|
export function openCollectiblesShop(a0) {
|
|
a0.tab;
|
|
const { tab, ...rest } = a0;
|
|
openCollectiblesShopMobile(rest);
|
|
}
|
|
openCollectiblesShopMobile = function openCollectiblesShopMobile(rest) {
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_OPEN",
|
|
...rest
|
|
});
|
|
const rootNavigationRef = getRootNavigationRef();
|
|
if (rootNavigationRef != null && rootNavigationRef.isReady()) {
|
|
let screen = rest.screen;
|
|
if (screen == null) {
|
|
screen = rest.initialProductSkuId != null ? CollectiblesMobileShopScreen.SHOP_ALL : CollectiblesMobileShopScreen.FEATURED_PAGE;
|
|
}
|
|
const currentRoute = rootNavigationRef.getCurrentRoute();
|
|
if ((currentRoute == null ? void 0 : currentRoute.params?.screen) !== screen) {
|
|
rootNavigationRef.navigate({
|
|
name: "settings",
|
|
params: {
|
|
screen: UserSettingsSections.COLLECTIBLES_SHOP,
|
|
params: {
|
|
analyticsSource: rest.analyticsSource,
|
|
screen,
|
|
onNavigateAway: rest.onNavigateAway
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
export function closeCollectiblesShop() {
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_CLOSE"
|
|
});
|
|
popLayer();
|
|
}
|
|
export async function fetchCollectiblesPurchases() {
|
|
let c25615_2;
|
|
let c25615_3 = 0;
|
|
let c29620_0, c29620_1, c29620_2, c29620_3;
|
|
L19: {
|
|
try {
|
|
c29620_0 = void 0;
|
|
c29620_1 = void 0;
|
|
c29620_2 = void 0;
|
|
if (CollectiblesPurchaseStore.isFetching) {
|
|
break L19;
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PURCHASES_FETCH"
|
|
});
|
|
const r48 = DevSettingsStore.get("shop_show_debug_overlay");
|
|
c29620_0 = r48;
|
|
if (r48) {
|
|
addDebugLog("fetchCollectiblesPurchases started");
|
|
}
|
|
c25615_3 = 1;
|
|
const r51 = {
|
|
url: Endpoints.COLLECTIBLES_PURCHASES,
|
|
rejectWithError: true,
|
|
query: {
|
|
variants_return_style: ShopVariantsReturnStyle.VARIANTS_GROUP
|
|
}
|
|
};
|
|
if (r48) {
|
|
addDebugLog(`fetchCollectiblesPurchases request: ${JSON.stringify(r51, null, 2)}`);
|
|
}
|
|
c29620_1 = await HTTP.get(r51);
|
|
if (c29620_0) {
|
|
addDebugLog(`fetchCollectiblesPurchases completed with ${c29620_1.body.length} purchases`);
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PURCHASES_FETCH_SUCCESS",
|
|
purchases: c29620_1.body.map(CollectiblesPurchaseRecord.fromServer)
|
|
});
|
|
c25615_3 = 0;
|
|
} catch ($e) {
|
|
const r36 = $e;
|
|
let r8 = r36;
|
|
c25615_2 = r36;
|
|
if (c25615_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r131 = c25615_2;
|
|
c25615_3 = 0;
|
|
c29620_3 = r131;
|
|
c29620_2 = new APIError(c29620_3);
|
|
captureOrIgnoreApiError(c29620_2);
|
|
if (c29620_0) {
|
|
addDebugLog(`fetchCollectiblesPurchases failed: ${c29620_2.message}`);
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PURCHASES_FETCH_FAILURE",
|
|
error: c29620_2
|
|
});
|
|
throw c29620_2;
|
|
} catch (r127) {
|
|
r8 = r127;
|
|
c25615_2 = r127;
|
|
if (c25615_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
fetchCollectiblesProduct = async function fetchCollectiblesProduct(skuId, c25616_1) {
|
|
let c25616_4;
|
|
let c25616_5 = 0;
|
|
let c29621_0, c29621_1, c29621_2, c29621_3;
|
|
L28: {
|
|
try {
|
|
c29621_0 = skuId;
|
|
c29621_1 = void 0;
|
|
c29621_2 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PRODUCT_FETCH",
|
|
skuId,
|
|
startedAt: Date.now()
|
|
});
|
|
c25616_5 = 1;
|
|
const query = {
|
|
locale: LocaleStore.locale
|
|
};
|
|
if (c25616_1?.countryCode !== null) {
|
|
query.country_code = c25616_1?.countryCode;
|
|
}
|
|
if (c25616_1?.paymentGateway !== null) {
|
|
query.payment_gateway = c25616_1?.paymentGateway;
|
|
}
|
|
if (c25616_1?.includeBundles !== null) {
|
|
query.include_bundles = c25616_1?.includeBundles;
|
|
}
|
|
c29621_1 = await HTTP.get({
|
|
url: Endpoints.COLLECTIBLES_PRODUCTS(skuId),
|
|
rejectWithError: true,
|
|
query
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PRODUCT_FETCH_SUCCESS",
|
|
skuId: c29621_0,
|
|
product: CollectiblesProductRecord.fromServer(c29621_1.body),
|
|
endedAt: Date.now()
|
|
});
|
|
c25616_5 = 0;
|
|
} catch ($e) {
|
|
const r29 = $e;
|
|
let r8 = r29;
|
|
c25616_4 = r29;
|
|
if (c25616_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r107 = c25616_4;
|
|
c25616_5 = 0;
|
|
c29621_3 = r107;
|
|
c29621_2 = new APIError(c29621_3);
|
|
captureOrIgnoreApiError(c29621_2);
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PRODUCT_FETCH_FAILURE",
|
|
skuId: c29621_0,
|
|
error: c29621_2,
|
|
endedAt: Date.now()
|
|
});
|
|
break L28;
|
|
} catch (r103) {
|
|
r8 = r103;
|
|
c25616_4 = r103;
|
|
if (c25616_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
};
|
|
export async function claimPremiumCollectiblesProduct(skuId2) {
|
|
let c25618_3;
|
|
let c25618_4 = 0;
|
|
let c29622_0, c29622_1, c29622_2, c29622_3;
|
|
try {
|
|
c29622_0 = skuId2;
|
|
c29622_1 = void 0;
|
|
c29622_2 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CLAIM",
|
|
skuId: skuId2
|
|
});
|
|
c25618_4 = 1;
|
|
c29622_1 = await HTTP.put({
|
|
url: Endpoints.COLLECTIBLES_CLAIM,
|
|
body: {
|
|
sku_id: skuId2
|
|
},
|
|
rejectWithError: true
|
|
});
|
|
const body = c29622_1.body;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CLAIM_SUCCESS",
|
|
skuId: c29622_0,
|
|
purchases: body == null ? void 0 : body.map(CollectiblesPurchaseRecord.fromServer)
|
|
});
|
|
c25618_4 = 0;
|
|
} catch ($e) {
|
|
const r28 = $e;
|
|
let r8 = r28;
|
|
c25618_3 = r28;
|
|
if (c25618_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r86 = c25618_3;
|
|
c25618_4 = 0;
|
|
c29622_3 = r86;
|
|
c29622_2 = new APIError(c29622_3);
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CLAIM_FAILURE",
|
|
skuId: c29622_0,
|
|
error: c29622_2
|
|
});
|
|
throw c29622_2;
|
|
} catch (r82) {
|
|
r8 = r82;
|
|
c25618_3 = r82;
|
|
if (c25618_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
Routes;
|
|
const r69 = {
|
|
openCollectiblesShop,
|
|
closeCollectiblesShop,
|
|
fetchCollectiblesPurchases,
|
|
fetchCollectiblesProduct,
|
|
claimPremiumCollectiblesProduct
|
|
};
|
|
export default r69;
|
|
export { openCollectiblesShopMobile };
|
|
export function isCollectiblesShopOpen() {
|
|
const rootNavigationRef = getRootNavigationRef();
|
|
const r1 = rootNavigationRef == null || !rootNavigationRef.isReady();
|
|
let r2 = !r1;
|
|
if (!r1) {
|
|
let searchRoutes2;
|
|
const isCollectiblesShopRoute2 = function isCollectiblesShopRoute(a0) {
|
|
return !(a0.name !== "settings" || a0.params?.screen !== UserSettingsSections.COLLECTIBLES_SHOP || false);
|
|
};
|
|
const rootState = rootNavigationRef.getRootState();
|
|
const routes = rootState?.routes;
|
|
let r20 = null;
|
|
if (routes) {
|
|
searchRoutes2 = function searchRoutes(a0) {
|
|
for (const item of a0) {
|
|
const isCollectiblesShopRoute22 = isCollectiblesShopRoute2(item);
|
|
if (!isCollectiblesShopRoute22) {
|
|
if (!item.state?.routes) {
|
|
continue;
|
|
}
|
|
const r34 = searchRoutes2(item.state.routes);
|
|
if (!r34) {
|
|
continue;
|
|
}
|
|
return r34;
|
|
}
|
|
return item;
|
|
}
|
|
return null;
|
|
};
|
|
r20 = searchRoutes2(rootState.routes);
|
|
}
|
|
r2 = r20 != null;
|
|
}
|
|
return r2;
|
|
}
|
|
export function dispatchOpenCollectiblesShop(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_OPEN",
|
|
...a0
|
|
});
|
|
}
|
|
export function productDetailsOpened(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PRODUCT_DETAILS_OPEN",
|
|
skuId: a0
|
|
});
|
|
}
|
|
export function areRequestOptionsEqual(a0, a1) {
|
|
const noCache = a0?.noCache;
|
|
const noCache2 = a1?.noCache;
|
|
let r14 = Boolean(noCache) === Boolean(noCache2);
|
|
if (r14) {
|
|
const includeUnpublished = a0?.includeUnpublished;
|
|
const includeUnpublished2 = a1?.includeUnpublished;
|
|
r14 = Boolean(includeUnpublished) === Boolean(includeUnpublished2);
|
|
}
|
|
if (r14) {
|
|
const includeBundles = a0?.includeBundles;
|
|
const includeBundles2 = a1?.includeBundles;
|
|
r14 = Boolean(includeBundles) === Boolean(includeBundles2);
|
|
}
|
|
if (r14) {
|
|
const includeDynamicBlocks = a0?.includeDynamicBlocks;
|
|
const includeDynamicBlocks2 = a1?.includeDynamicBlocks;
|
|
r14 = Boolean(includeDynamicBlocks) === Boolean(includeDynamicBlocks2);
|
|
}
|
|
if (r14) {
|
|
r14 = a0?.countryCode === a1?.countryCode;
|
|
}
|
|
if (r14) {
|
|
r14 = a0?.paymentGateway === a1?.paymentGateway;
|
|
}
|
|
if (r14) {
|
|
r14 = a0?.shopHomeConfig === a1?.shopHomeConfig;
|
|
}
|
|
if (r14) {
|
|
r14 = a0?.skipNumCategories === a1?.skipNumCategories;
|
|
}
|
|
return r14;
|
|
}
|
|
export async function fetchCollectiblesCategories(c25614_0, c25614_1, c25614_2) {
|
|
let options, c25614_6;
|
|
let c25614_7 = 0;
|
|
let c29619_0, c29619_1, c29619_2, c29619_3, c29619_4, c29619_5, c29619_6;
|
|
L40: {
|
|
try {
|
|
c29619_0 = c25614_0;
|
|
c29619_1 = c25614_1;
|
|
c29619_2 = c25614_2;
|
|
c29619_3 = void 0;
|
|
c29619_4 = void 0;
|
|
c29619_5 = void 0;
|
|
options = c25614_0;
|
|
if (c25614_0 == null) {
|
|
options = {};
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CATEGORIES_FETCH",
|
|
options
|
|
});
|
|
const query = buildFetchCollectiblesOptionsQuery(c25614_0);
|
|
const r54 = DevSettingsStore.get("shop_show_debug_overlay");
|
|
c29619_3 = r54;
|
|
if (c25614_0?.logPerf) {
|
|
trackShopPerf({
|
|
sessionId: c25614_2?.sessionId,
|
|
checkpoint: CollectiblesShopPerfCheckpoint.CATEGORIES_FETCH_STARTED,
|
|
tab: c25614_2?.tab,
|
|
unpublishedCategoriesShown: c25614_0?.includeUnpublished,
|
|
cacheDisabled: c25614_0?.noCache
|
|
});
|
|
}
|
|
if (r54) {
|
|
addDebugLog(`fetchCollectiblesCategories started: ${JSON.stringify(query, null, 2)}`);
|
|
}
|
|
c25614_7 = 1;
|
|
c29619_4 = await HTTP.get({
|
|
url: Endpoints.COLLECTIBLES_CATEGORIES_V2,
|
|
query,
|
|
rejectWithError: true
|
|
});
|
|
if (c29619_0?.logPerf) {
|
|
trackShopPerf({
|
|
sessionId: c29619_2?.sessionId,
|
|
checkpoint: CollectiblesShopPerfCheckpoint.CATEGORIES_FETCH_COMPLETED,
|
|
tab: c29619_2?.tab,
|
|
unpublishedCategoriesShown: c29619_0?.includeUnpublished,
|
|
cacheDisabled: c29619_0?.noCache
|
|
});
|
|
}
|
|
if (c29619_3) {
|
|
addDebugLog(`fetchCollectiblesCategories completed ${c29619_4.body.categories.length} categories`);
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CATEGORIES_FETCH_SUCCESS",
|
|
categories: CollectiblesCategoriesRecord.fromServer(c29619_4.body),
|
|
noOp: c29619_1
|
|
});
|
|
c25614_7 = 0;
|
|
} catch ($e) {
|
|
const r38 = $e;
|
|
let r8 = r38;
|
|
c25614_6 = r38;
|
|
if (c25614_7 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r187 = c25614_6;
|
|
c25614_7 = 0;
|
|
c29619_6 = r187;
|
|
c29619_5 = new APIError(c29619_6);
|
|
captureOrIgnoreApiError(c29619_5);
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CATEGORIES_FETCH_FAILURE",
|
|
error: c29619_5
|
|
});
|
|
if (!c29619_3) {
|
|
break L40;
|
|
}
|
|
addDebugLog(`fetchCollectiblesCategories failed: ${c29619_5.message}`);
|
|
break L40;
|
|
} catch (r183) {
|
|
r8 = r183;
|
|
c25614_6 = r183;
|
|
if (c25614_7 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
}
|
|
export { fetchCollectiblesProduct };
|
|
export async function maybeFetchCollectiblesProduct(c25617_0, c25617_1) {
|
|
L13: {
|
|
if (CollectiblesCategoryStore.isFetchingProduct(c25617_0) || CollectiblesCategoryStore.isProductFetchBackedOff(c25617_0)) {
|
|
break L13;
|
|
}
|
|
await fetchCollectiblesProduct(c25617_0, c25617_1);
|
|
return void 0;
|
|
}
|
|
}
|
|
export function seedCollectiblesProductFromStandaloneLoad(a0) {
|
|
const endedAt = Date.now();
|
|
for (const item of extendVariantsProducts([a0])) {
|
|
if (CollectiblesCategoryStore.getProduct(item.skuId) == null) {
|
|
const product = item;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_PRODUCT_FETCH_SUCCESS",
|
|
skuId: product.skuId,
|
|
product,
|
|
endedAt
|
|
});
|
|
}
|
|
}
|
|
}
|
|
export async function validateCollectiblesRecipient(recipient_id, sku_id) {
|
|
let valid;
|
|
let c25619_4;
|
|
let c25619_5 = 0;
|
|
let c29623_0;
|
|
try {
|
|
c25619_5 = 1;
|
|
valid = (await HTTP.get({
|
|
url: Endpoints.COLLECTIBLES_VALID_GIFT_RECIPIENT,
|
|
query: {
|
|
sku_id,
|
|
recipient_id
|
|
},
|
|
rejectWithError: true
|
|
})).body.valid;
|
|
c25619_5 = 0;
|
|
} catch ($e) {
|
|
const r26 = $e;
|
|
let r8 = r26;
|
|
c25619_4 = r26;
|
|
if (c25619_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r62 = c25619_4;
|
|
c25619_5 = 0;
|
|
c29623_0 = r62;
|
|
captureOrIgnoreApiError(new APIError(c29623_0));
|
|
} catch (r58) {
|
|
r8 = r58;
|
|
c25619_4 = r58;
|
|
if (c25619_5 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return valid;
|
|
}
|
|
export async function validateCollectiblesRecipientsBatch(recipient_id2, sku_ids) {
|
|
let body;
|
|
let c25620_4;
|
|
let c25620_5 = 0;
|
|
let c29624_0;
|
|
try {
|
|
c25620_5 = 1;
|
|
body = (await HTTP.get({
|
|
url: Endpoints.COLLECTIBLES_VALID_GIFT_RECIPIENTS_BATCH,
|
|
query: {
|
|
sku_ids,
|
|
recipient_id: recipient_id2
|
|
},
|
|
rejectWithError: true
|
|
})).body;
|
|
c25620_5 = 0;
|
|
} catch ($e) {
|
|
const r26 = $e;
|
|
let r8 = r26;
|
|
c25620_4 = r26;
|
|
if (c25620_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r61 = c25620_4;
|
|
c25620_5 = 0;
|
|
c29624_0 = r61;
|
|
captureOrIgnoreApiError(new APIError(c29624_0));
|
|
} catch (r57) {
|
|
r8 = r57;
|
|
c25620_4 = r57;
|
|
if (c25620_5 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return {};
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return body;
|
|
}
|
|
export async function fetchCollectiblesMarketings(c25621_0) {
|
|
let c25621_3;
|
|
let c25621_4 = 0;
|
|
let c29625_0, c29625_1, c29625_2, c29625_3;
|
|
L16: {
|
|
try {
|
|
c29625_0 = void 0;
|
|
let release = c25621_0.release;
|
|
if (release === void 0) {
|
|
release = CollectiblesMarketingReleaseType.PROD;
|
|
}
|
|
c29625_0 = release;
|
|
c29625_1 = void 0;
|
|
c29625_2 = void 0;
|
|
await void 0;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_MARKETING_FETCH"
|
|
});
|
|
c29625_1 = {
|
|
platform: CollectiblesMarketingPlatform.MOBILE
|
|
};
|
|
if (c29625_0 !== CollectiblesMarketingReleaseType.PROD) {
|
|
c29625_1.release = c29625_0;
|
|
}
|
|
c25621_4 = 1;
|
|
c29625_2 = await HTTP.get({
|
|
url: Endpoints.COLLECTIBLES_MARKETING,
|
|
query: c29625_1,
|
|
rejectWithError: true
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_MARKETING_FETCH_SUCCESS",
|
|
marketings: CollectiblesMarketingsRecord.fromServer(c29625_2.body)
|
|
});
|
|
c25621_4 = 0;
|
|
} catch ($e) {
|
|
const r28 = $e;
|
|
let r8 = r28;
|
|
c25621_3 = r28;
|
|
if (c25621_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r124 = c25621_3;
|
|
c25621_4 = 0;
|
|
c29625_3 = r124;
|
|
captureOrIgnoreApiError(new APIError(c29625_3));
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_MARKETING_FETCH_FAILURE"
|
|
});
|
|
break L16;
|
|
} catch (r120) {
|
|
r8 = r120;
|
|
c25621_3 = r120;
|
|
if (c25621_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
}
|
|
export async function fetchCollectiblesShopHome(tab, c25622_1, c25622_2) {
|
|
let options2, c25622_6;
|
|
let c25622_7 = 0;
|
|
let c29626_0, c29626_1, c29626_2, c29626_3, c29626_4, c29626_5;
|
|
L36: {
|
|
try {
|
|
c29626_0 = tab;
|
|
c29626_1 = c25622_1;
|
|
c29626_2 = c25622_2;
|
|
c29626_3 = void 0;
|
|
c29626_4 = void 0;
|
|
options2 = c25622_1;
|
|
if (c25622_1 == null) {
|
|
options2 = {};
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_HOME_FETCH",
|
|
tab,
|
|
options: options2
|
|
});
|
|
const query = buildFetchCollectiblesOptionsQuery(c25622_1, tab);
|
|
if (c25622_1?.logPerf) {
|
|
trackShopPerf({
|
|
sessionId: c25622_2?.sessionId,
|
|
checkpoint: CollectiblesShopPerfCheckpoint.SHOP_HOME_FETCH_STARTED,
|
|
tab: c25622_2?.tab,
|
|
unpublishedCategoriesShown: c25622_1?.includeUnpublished,
|
|
cacheDisabled: c25622_1?.noCache
|
|
});
|
|
}
|
|
c25622_7 = 1;
|
|
c29626_3 = await HTTP.get({
|
|
url: Endpoints.COLLECTIBLES_SHOP,
|
|
query,
|
|
rejectWithError: true
|
|
});
|
|
if (c29626_1?.logPerf) {
|
|
trackShopPerf({
|
|
sessionId: c29626_2?.sessionId,
|
|
checkpoint: CollectiblesShopPerfCheckpoint.SHOP_HOME_FETCH_COMPLETED,
|
|
tab: c29626_2?.tab,
|
|
unpublishedCategoriesShown: c29626_1?.includeUnpublished,
|
|
cacheDisabled: c29626_1?.noCache
|
|
});
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_HOME_FETCH_SUCCESS",
|
|
tab: c29626_0,
|
|
shopHome: CollectiblesShopHomeRecord.fromServer(c29626_3.body)
|
|
});
|
|
c25622_7 = 0;
|
|
} catch ($e) {
|
|
const r30 = $e;
|
|
let r8 = r30;
|
|
c25622_6 = r30;
|
|
if (c25622_7 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r151 = c25622_6;
|
|
c25622_7 = 0;
|
|
c29626_5 = r151;
|
|
c29626_4 = new APIError(c29626_5);
|
|
captureOrIgnoreApiError(c29626_4);
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_HOME_FETCH_FAILURE",
|
|
tab: c29626_0,
|
|
error: c29626_4
|
|
});
|
|
break L36;
|
|
} catch (r147) {
|
|
r8 = r147;
|
|
c25622_6 = r147;
|
|
if (c25622_7 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
}
|
|
export function setShopHomeConfigOverride(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SET_SHOP_HOME_CONFIG_OVERRIDE",
|
|
shopHomeConfigOverride: a0
|
|
});
|
|
}
|
|
export function setShopLayoutUrlOverride(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SET_SHOP_LAYOUT_URL_OVERRIDE",
|
|
shopLayoutUrlOverride: a0
|
|
});
|
|
}
|
|
export function setSkipNumCategories(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SKIP_NUM_CATEGORIES",
|
|
skipNumCategories: a0
|
|
});
|
|
}
|
|
export async function claimCollectiblesCategoryReward(category_id, skuId3) {
|
|
let c25623_4;
|
|
let c25623_5 = 0;
|
|
let c29627_0, c29627_1, c29627_2, c29627_3;
|
|
try {
|
|
c29627_0 = skuId3;
|
|
c29627_1 = void 0;
|
|
c29627_2 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CLAIM",
|
|
skuId: skuId3
|
|
});
|
|
c25623_5 = 1;
|
|
c29627_1 = await HTTP.put({
|
|
url: Endpoints.COLLECTIBLES_CLAIM_CATEGORY_REWARD,
|
|
body: {
|
|
category_id
|
|
},
|
|
rejectWithError: true
|
|
});
|
|
const body = c29627_1.body;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CLAIM_SUCCESS",
|
|
skuId: c29627_0,
|
|
purchases: body == null ? void 0 : body.map(CollectiblesPurchaseRecord.fromServer)
|
|
});
|
|
c25623_5 = 0;
|
|
} catch ($e) {
|
|
const r28 = $e;
|
|
let r8 = r28;
|
|
c25623_4 = r28;
|
|
if (c25623_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r87 = c25623_4;
|
|
c25623_5 = 0;
|
|
c29627_3 = r87;
|
|
c29627_2 = new APIError(c29627_3);
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_CLAIM_FAILURE",
|
|
skuId: c29627_0,
|
|
error: c29627_2
|
|
});
|
|
throw c29627_2;
|
|
} catch (r83) {
|
|
r8 = r83;
|
|
c25623_4 = r83;
|
|
if (c25623_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
export async function maybeFetchCollectiblesShopTabLayout(c25624_0) {
|
|
let c25624_3;
|
|
let c25624_4 = 0;
|
|
let c29628_0, c29628_1, c29628_2, c29628_3, c29628_4, c29628_5;
|
|
try {
|
|
c29628_0 = void 0;
|
|
c29628_1 = void 0;
|
|
c29628_0 = c25624_0.tab;
|
|
c29628_1 = c25624_0.abortSignal;
|
|
c29628_2 = void 0;
|
|
c29628_3 = void 0;
|
|
c29628_4 = void 0;
|
|
await void 0;
|
|
if (!CollectiblesShopStore.isFetchingLayout(c29628_0)) {
|
|
c29628_2 = CollectiblesShopStore.getLayoutFetchError(c29628_0);
|
|
if (c29628_2?.status !== 404) {
|
|
if (c29628_2?.status !== 429) {
|
|
c25624_4 = 1;
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_TAB_LAYOUT_FETCH",
|
|
tab: c29628_0
|
|
});
|
|
c29628_3 = await HTTP.get({
|
|
url: Endpoints.COLLECTIBLES_SHOP_TAB_LAYOUT(c29628_0),
|
|
rejectWithError: true,
|
|
signal: c29628_1
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_TAB_LAYOUT_FETCH_SUCCESS",
|
|
tab: c29628_0,
|
|
layoutId: c29628_3.body.layout_id
|
|
});
|
|
c25624_4 = 0;
|
|
}
|
|
}
|
|
}
|
|
} catch ($e) {
|
|
const r32 = $e;
|
|
let r8 = r32;
|
|
c25624_3 = r32;
|
|
if (c25624_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r131 = c25624_3;
|
|
c25624_4 = 0;
|
|
c29628_5 = r131;
|
|
c29628_4 = new APIError(c29628_5);
|
|
Dispatcher.dispatch({
|
|
type: "COLLECTIBLES_SHOP_TAB_LAYOUT_FETCH_FAILURE",
|
|
tab: c29628_0,
|
|
apiError: c29628_4
|
|
});
|
|
throw c29628_4;
|
|
} catch (r127) {
|
|
r8 = r127;
|
|
c25624_3 = r127;
|
|
if (c25624_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|