decord/source/modules/premium/promotions/PromotionsManager.tsx

220 lines
8.2 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 16783
// Function ID: 16784
2026-07-29 08:29:29 +00:00
// Name: _terminate
2026-08-24 06:08:38 +00:00
// Dependencies: [5, 1995, 1922, 4048, 7666, 1924, 676, 505, 5043, 7967, 4042, 12953, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 16783 (_terminate)
import initializeDefault from "initialize" /* 5043 */;
import fetchActivePromotions from "fetchActivePromotions" /* 7967 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import closure_4 from "_getSystemLocale" /* 1995 */;
import closure_5 from "mergeGuildAvatar" /* 1922 */;
import closure_6 from "reset" /* 4048 */;
import closure_7 from "createEmptyPromotionsByType" /* 7666 */;
import { PremiumTypes } from "GuildFeatures" /* 1924 */;
import { EntitlementTypes } from "ME" /* 676 */;
import { SubscriptionTypes } from "sum" /* 505 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
initializeDefault;
2026-07-29 08:29:29 +00:00
class PromotionsManager extends tmp2 {
constructor() {
applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
obj = { POST_CONNECTION_OPEN: onPostConnectionOpen.bind(applyArgumentsResult), EXPERIMENTS_FETCH_SUCCESS: onPostConnectionOpen2.bind(applyArgumentsResult), IAP_PURCHASE_PRODUCT_SUCCESS: onMobilePurchaseSuccess.bind(applyArgumentsResult), GPLAY_PURCHASE_VERIFIED: onMobilePurchaseSuccess2.bind(applyArgumentsResult), BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS: onOfferUpdated.bind(applyArgumentsResult), BILLING_USER_TRIAL_OFFER_ACKNOWLEDGED_SUCCESS: onOfferUpdated2.bind(applyArgumentsResult), BILLING_REFERRAL_RESOLVE_SUCCESS: onOfferUpdated3.bind(applyArgumentsResult), VIRTUAL_CURRENCY_REDEEM_SUCCESS: onVCRedeemed.bind(applyArgumentsResult) };
({ onPostConnectionOpen, onPostConnectionOpen: onPostConnectionOpen2, onMobilePurchaseSuccess, onMobilePurchaseSuccess: onMobilePurchaseSuccess2, onOfferUpdated, onOfferUpdated: onOfferUpdated2, onOfferUpdated: onOfferUpdated3, onVCRedeemed } = applyArgumentsResult);
applyArgumentsResult.actions = obj;
map = new Map();
onLocaleChanged = applyArgumentsResult.onLocaleChanged;
2026-08-24 06:08:38 +00:00
result = map.set(closure_4, onLocaleChanged.bind(applyArgumentsResult));
2026-07-29 08:29:29 +00:00
onSubscriptionStateChanged = applyArgumentsResult.onSubscriptionStateChanged;
2026-08-24 06:08:38 +00:00
result1 = result.set(closure_6, onSubscriptionStateChanged.bind(applyArgumentsResult));
2026-07-29 08:29:29 +00:00
onPromotionsFetchSettled = applyArgumentsResult.onPromotionsFetchSettled;
2026-08-24 06:08:38 +00:00
applyArgumentsResult.stores = result1.set(closure_7, onPromotionsFetchSettled.bind(applyArgumentsResult));
2026-07-29 08:29:29 +00:00
applyArgumentsResult.lastSubscriptionStateSignature = null;
applyArgumentsResult.hasPendingSubscriptionRefetch = false;
2026-08-24 06:08:38 +00:00
applyArgumentsResult.maybeFetchBogoPromotion = closure_3(function*() {
2026-07-29 08:29:29 +00:00
if (v0 === 2) {
v0 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
v0 = 2;
if (0 === v02) {
if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
const currentUser = closure_1_5.getCurrentUser();
if (!obj6.isPremiumExactly(currentUser, closure_1_8.TIER_2)) {
obj1 = v0(tmp15[11]);
2026-07-29 08:29:29 +00:00
v02 = 1;
v0 = 1;
obj1 = { value: null, done: false };
obj1[0] = obj1.maybeFetchActiveBogoPromotion();
return obj1;
}
2026-08-24 06:08:38 +00:00
obj6 = v02(closure_1_2[10]);
tmp15 = closure_1_2;
2026-07-29 08:29:29 +00:00
}
} else if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
}
v0 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
} catch (tmp6) {
v0 = tmp;
throw tmp6;
}
}
});
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const prototype = PromotionsManager.prototype;
prototype["_terminate"] = function _terminate() {
this.hasPendingSubscriptionRefetch = false;
this.lastSubscriptionStateSignature = null;
};
prototype["onLocaleChanged"] = function onLocaleChanged() {
2026-08-24 06:08:38 +00:00
let tmp = null != closure_7.lastFetchedActivePromotions;
2026-07-29 08:29:29 +00:00
if (tmp) {
2026-08-24 06:08:38 +00:00
tmp = closure_7.lastFetchedActivePromotionsLocale !== locale.locale;
2026-07-29 08:29:29 +00:00
}
if (tmp) {
2026-08-24 06:08:38 +00:00
const result = fetchActivePromotions.maybeFetchActivePromotions(false);
const obj = fetchActivePromotions;
2026-07-29 08:29:29 +00:00
}
};
prototype["onPostConnectionOpen"] = function onPostConnectionOpen() {
const self = this;
return callback(function*() {
if (v0 === 2) {
v0 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
v0 = 2;
if (0 === c1) {
if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
obj1 = v0(closure_1_2[9]);
2026-07-29 08:29:29 +00:00
const result = obj1.maybeFetchActivePromotions();
c1 = 1;
v0 = 1;
obj1 = { value: null, done: false };
obj1[0] = v0.maybeFetchBogoPromotion();
return obj1;
}
} else if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
v0 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} catch (tmp9) {
v0 = tmp;
throw tmp9;
}
}
})();
};
prototype["onSubscriptionStateChanged"] = function onSubscriptionStateChanged() {
subscriptions = subscriptions.getSubscriptions(false);
let str = "";
if (null != subscriptions) {
const _Object = Object;
const values = Object.values(subscriptions);
2026-08-12 06:57:52 +00:00
const found = values.filter((type) => type.type === constants.PREMIUM);
let mapped = found.map((items) => {
2026-07-29 08:29:29 +00:00
items = items.items;
const mapped = items.map((planId) => planId.planId);
const sorted = mapped.sort();
return "" + items.id + ":" + items.type + ":" + items.status + ":" + sorted.join("|");
});
let sorted = mapped.sort();
str = sorted.join(",");
}
const self = this;
if (str !== this.lastSubscriptionStateSignature) {
self.lastSubscriptionStateSignature = str;
2026-08-12 06:57:52 +00:00
if (!tmp3) {
2026-08-24 06:08:38 +00:00
if (closure_7.isFetchingActivePromotions) {
2026-07-29 08:29:29 +00:00
self.hasPendingSubscriptionRefetch = true;
} else {
2026-08-24 06:08:38 +00:00
const result = fetchActivePromotions.maybeFetchActivePromotions(false);
const obj3 = fetchActivePromotions;
2026-07-29 08:29:29 +00:00
}
}
}
};
prototype["onPromotionsFetchSettled"] = function onPromotionsFetchSettled() {
if (this.hasPendingSubscriptionRefetch) {
2026-08-24 06:08:38 +00:00
if (!closure_7.isFetchingActivePromotions) {
2026-07-29 08:29:29 +00:00
tmp.hasPendingSubscriptionRefetch = false;
2026-08-24 06:08:38 +00:00
const result = fetchActivePromotions.maybeFetchActivePromotions(false);
const obj = fetchActivePromotions;
2026-07-29 08:29:29 +00:00
}
}
};
prototype["onMobilePurchaseSuccess"] = function onMobilePurchaseSuccess() {
2026-08-24 06:08:38 +00:00
const result = fetchActivePromotions.maybeFetchActivePromotions(false);
2026-07-29 08:29:29 +00:00
};
prototype["onOfferUpdated"] = function onOfferUpdated() {
2026-08-24 06:08:38 +00:00
const result = fetchActivePromotions.maybeFetchActivePromotions(false);
2026-07-29 08:29:29 +00:00
};
prototype["onVCRedeemed"] = function onVCRedeemed(entitlements) {
entitlements = entitlements.entitlements;
if (entitlements.some((type) => type.type === constants.FRACTIONAL_REDEMPTION)) {
2026-08-24 06:08:38 +00:00
const result = fetchActivePromotions.maybeFetchActivePromotions(false);
const obj = fetchActivePromotions;
2026-07-29 08:29:29 +00:00
}
};
const promotionsManager = new PromotionsManager();
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/premium/promotions/PromotionsManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default promotionsManager;