Files
discord-decomp/modules/collectibles/CollectiblesPurchaseStore.tsx
T
2026-11-01 12:12:55 +02:00

94 lines
2.5 KiB
TypeScript

// Metro module 5814 (f5815).
import { isEqual } from "../../_bundle/Module12";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let skuId, error, error2;
let c3627_2 = new Map();
let c3627_3 = c3627_2;
let c3627_4 = false;
skuId = void 0;
error = void 0;
error2 = void 0;
let c3627_8 = false;
class CollectiblesPurchaseStore extends Module589.Store {
static displayName = "CollectiblesPurchaseStore";
get isFetching() {
return c3627_4;
}
get isClaiming() {
return skuId;
}
get purchases() {
return c3627_3;
}
get fetchError() {
return error;
}
get claimError() {
return error2;
}
get hasPreviouslyFetched() {
return c3627_8;
}
getPurchase(a0) {
return a0 != null ? c3627_3.get(a0) : void 0;
}
getPurchases(a0) {
return a0.map((item) => c3627_3.get(item)).filter((item) => item != null);
}
}
const collectiblesPurchaseStore = new CollectiblesPurchaseStore(Dispatcher, {
COLLECTIBLES_PURCHASES_FETCH: function handlePurchasesFetch() {
c3627_4 = true;
error = void 0;
},
COLLECTIBLES_PURCHASES_FETCH_SUCCESS: function handlePurchasesFetchSuccess(a0) {
if (a0.purchases.length === 0) {
c3627_3 = c3627_2;
} else if (!isEqual([...c3627_3.values()], a0.purchases)) {
c3627_3 = new Map(a0.purchases.map((purchase) => [purchase.skuId, purchase]));
}
c3627_8 = true;
c3627_4 = false;
error = void 0;
},
COLLECTIBLES_PURCHASES_FETCH_FAILURE: function handlePurchasesFetchFailure({ error: error3 }) {
c3627_3 = c3627_2;
c3627_4 = false;
error = error3;
c3627_8 = true;
},
COLLECTIBLES_CLAIM: function handleClaim(a0) {
skuId = a0.skuId;
error2 = void 0;
},
COLLECTIBLES_CLAIM_SUCCESS: function handleClaimSuccess(a0) {
L5: {
if (a0.purchases != null && a0.purchases.length !== 0) {
if (isEqual([...c3627_3.values()], a0.purchases)) {
break L5;
}
c3627_3 = new Map(a0.purchases.map((purchase) => [purchase.skuId, purchase]));
} else {
c3627_3 = c3627_2;
}
}
skuId = void 0;
error2 = void 0;
},
COLLECTIBLES_CLAIM_FAILURE: function handleClaimFailure(a0) {
const error3 = a0.error;
skuId = a0.skuId;
error2 = error3;
},
LOGOUT: function handleLogout() {
c3627_3 = c3627_2;
c3627_4 = false;
skuId = void 0;
error = void 0;
error2 = void 0;
c3627_8 = false;
}
});
export default collectiblesPurchaseStore;