Files
discord-decomp/sources/modules/premium/promotions/PromotionsHooks.tsx
T
2026-07-27 16:20:00 +03:00

256 lines
14 KiB
TypeScript

/* Metro module 7285; source: modules/premium/promotions/PromotionsHooks.tsx; dependencies: [31, 1878, 7064, 7261, 1880, 566, 7286, 7287, 7288, 3802, 694, 7289, 2] */
function _fun58735(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#58735, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:6, offset: 0x016d5cc1, size: 228 bytes, params: 8, frame: 20
const env0_0 = require;
const closure = useEligibleActiveOutboundPromotions;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importAll(31) /* metro dependency 31 */;
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
const userOfferStore = importDefault(7064) /* metro dependency 7064: UserOfferStore */;
const promotionsStore = importDefault(7261) /* metro dependency 7261: PromotionsStore */;
const env0_7 = (require(1880) /* metro dependency 1880: PremiumConstants */).PremiumTypes;
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/premium/promotions/PromotionsHooks.tsx');
exports.useEligibleActiveOutboundPromotions = closure;
exports.useOutboundPromotions = useOutboundPromotions;
exports.useUnseenOutboundPromotions = useUnseenOutboundPromotions;
exports.useBogoPromotion = function() {
var object = {};
object.promotion = require(dependencyMap[5]).useStateFromStores([PromotionsStore], _fun58764);
return object;
};
}
function useEligibleActiveOutboundPromotions(a0, a1, a2, a3) { // fn#58736, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:159, offset: 0x016d5da5, size: 179 bytes, params: 5, frame: 23
const env0_0 = a0;
const env0_1 = a1;
const env0_2 = a2;
return a3.useMemo(_fun58739,
[(require(566) /* metro dependency 566: flux */).useStateFromStoresArray([PromotionsStore], function() {
return PromotionsStore.outboundPromotions;
}), (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore], function() {
return PromotionsStore.consumedInboundPromotionId;
}), a2, a0, a1, a3]);
}
function useOutboundPromotions() { // fn#58741, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:754, offset: 0x016d5f45, size: 564 bytes, params: 1, frame: 26
var r4;
const lastFetchedActivePromotions = (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore],
function() {
return PromotionsStore.lastFetchedActivePromotions;
});
const currentUser = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], function() {
return UserStore.getCurrentUser();
});
const value2 = (require(7287) /* metro dependency 7287: PremiumSubscriptionTrialUtil */).useHasActiveTrial();
const value3 = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserOfferStore], function() {
return UserOfferStore.hasAnyUnexpiredOffer();
});
const value4 = (require(7288) /* metro dependency 7288: ReverseTrialUtilsNative */).useIsInReverseTrial();
const defaultImport = importDefault(3802) /* metro dependency 3802: PremiumUtils */;
const isPremiumExactly = defaultImport.isPremiumExactly;
const TIER_2 = PremiumTypes.TIER_2;
const isPremiumExactly2 = Reflect.apply(isPremiumExactly, defaultImport, [currentUser, TIER_2]);
const isPremium2 = defaultImport.isPremium(currentUser);
let r5 = isPremium2 ? isPremiumExactly2 : !isPremium2;
const claimedOutboundPromotionCodes = (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore],
function() {
return PromotionsStore.claimedOutboundPromotionCodes;
});
const env0_3 = claimedOutboundPromotionCodes;
const claimedOutboundPromotionCodesLoaded = (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore],
function() {
return PromotionsStore.claimedOutboundPromotionCodesLoaded;
});
env0_3.useEffect(_fun58747, [lastFetchedActivePromotions, value4]);
env0_3.useEffect(_fun58749, [lastFetchedActivePromotions, r5, value4]);
env0_3.useEffect(_fun58751, []);
const value6 = env0_3.useMemo(_fun58753, [claimedOutboundPromotionCodes]);
const value7 = useEligibleActiveOutboundPromotions(value2, value3, value4, value6);
const value = env0_3.useMemo(_fun58754, [value7, claimedOutboundPromotionCodes]);
if (claimedOutboundPromotionCodesLoaded) {
r5 = r5 ? lastFetchedActivePromotions != null : !r5;
r5 = !r5 ? value4 : r5;
r4 = r5;
} else {
r4 = claimedOutboundPromotionCodesLoaded;
}
return {promotionsLoaded: r4, activeOutboundPromotions: value7, claimedEndedOutboundPromotions: value,
claimedOutboundPromotionCodeMap: value6};
}
function useUnseenOutboundPromotions() { // fn#58757, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2111, offset: 0x016d6428, size: 208 bytes, params: 1, frame: 23
const fluxModule = require(566) /* metro dependency 566: flux */;
let useStateFromStores = fluxModule.useStateFromStores;
const lastSeenOutboundPromotionStartDate = Reflect.apply(useStateFromStores, fluxModule, [[PromotionsStore],
function() {
return PromotionsStore.lastSeenOutboundPromotionStartDate;
}]);
const value2 = (require(7287) /* metro dependency 7287: PremiumSubscriptionTrialUtil */).useHasActiveTrial();
const moduleValue3 = fluxModule;
useStateFromStores = moduleValue3.useStateFromStores;
const value5 = useEligibleActiveOutboundPromotions(value2, Reflect.apply(useStateFromStores, moduleValue3,
[[UserOfferStore], function() {
return UserOfferStore.hasAnyUnexpiredOffer();
}]), (require(7288) /* metro dependency 7288: ReverseTrialUtilsNative */).useIsInReverseTrial(), {});
const binding = env0_3;
const useMemo = binding.useMemo;
return Reflect.apply(useMemo, binding, [_fun58760, [value5, lastSeenOutboundPromotionStartDate]]).filter(_fun58762);
}
function useBogoPromotion() { // fn#58763, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2569, offset: 0x016d65a6, size: 64 bytes, params: 1, frame: 14
const fluxModule = require(566) /* metro dependency 566: flux */;
const useStateFromStores = fluxModule.useStateFromStores;
return {promotion: Reflect.apply(useStateFromStores, fluxModule, [[PromotionsStore], function() {
return PromotionsStore.bogoPromotion;
}])};
}
function _fun58739() { // fn#58739, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:370, offset: 0x016d5e76, size: 26 bytes, params: 1, frame: 11
return env0_4.filter(_fun58740);
}
function _fun58747() { // fn#58747, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1276, offset: 0x016d61cd, size: 70 bytes, params: 1, frame: 11
var environment;
var value;
if (lastFetchedActivePromotions != null || env0_1) {
value = environment.__proto__;
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.wait(_fun58748);
}
}
function _fun58749() { // fn#58749, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1376, offset: 0x016d6238, size: 45 bytes, params: 1, frame: 12
var environment;
const value = environment.__proto__;
(importDefault(694) /* metro dependency 694: Dispatcher */).wait(_fun58750);
}
function _fun58751() { // fn#58751, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1478, offset: 0x016d62ad, size: 45 bytes, params: 1, frame: 12
var environment;
const value = environment.__proto__;
(importDefault(694) /* metro dependency 694: Dispatcher */).wait(_fun58752);
}
function _fun58753() { // fn#58753, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1575, offset: 0x016d62ff, size: 45 bytes, params: 1, frame: 11
const value = environment.__proto__;
return (require(7286) /* metro dependency 7286: PromotionUtils */).getClaimedOutboundPromotionCodeMap(claimedOutboundPromotionCodes);
}
function _fun58754() { // fn#58754, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1691, offset: 0x016d632c, size: 77 bytes, params: 1, frame: 14
const Set = global.Set;
const set = new Set(env0_4.map(function(a0) {
return a0.id;
}));
return claimedOutboundPromotionCodes.filter(_fun58756);
}
function _fun58760() { // fn#58760, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2412, offset: 0x016d6507, size: 42 bytes, params: 1, frame: 12
return lastSeenOutboundPromotionStartDate == null ? env0_1 : env0_1.filter(function({startDate}) {
var Date = global.Date;
var value2 = new Date(startDate);
startDate = global.Date;
var lastSeenOutboundPromotionStartDateBinding = lastSeenOutboundPromotionStartDate;
var value4 = Object.create(startDate.prototype, {constructor: {value: startDate}});
var value5 = new startDate(lastSeenOutboundPromotionStartDateBinding);
return value2 > (value5 instanceof Object ? value5 : value4);
});
}
function _fun58762(a0) { // fn#58762, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2495, offset: 0x016d657d, size: 41 bytes, params: 2, frame: 11
const value = environment.__proto__;
return (require(7286) /* metro dependency 7286: PromotionUtils */).shouldShowOutboundPromotionOnPlatform(a0);
}
function _fun58740(a0) { // fn#58740, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:384, offset: 0x016d5e90, size: 181 bytes, params: 2, frame: 20
var r4;
var r3;
var r2;
var r1;
var r0;
var value3;
var shouldShowOutboundPromotionOnPlatform2;
var isLogitechPromotion2;
const id = a0.id;
const value = environment.__proto__;
const value2 = id !== consumedInboundPromotionId;
if (value2) {
value3 = environment.__proto__.__proto__;
shouldShowOutboundPromotionOnPlatform2 = (require(7286) /* metro dependency 7286: PromotionUtils */).shouldShowOutboundPromotionOnPlatform(a0);
if (shouldShowOutboundPromotionOnPlatform2) {
if (importDefault) {
r2 = !importDefault;
} else {
isLogitechPromotion2 = (require(7286) /* metro dependency 7286: PromotionUtils */).isLogitechPromotion(a0);
if (isLogitechPromotion2) {
r3 = !isLogitechPromotion2;
} else {
r4 = !env1_0 && !require;
r4 = !r4 ? (require(7286) /* metro dependency 7286: PromotionUtils */).isTrialUserEligibleToSeeOutboundPromotion(a0,
importAll) : r4;
r3 = r4;
}
r2 = r3;
}
r1 = r2;
} else {
r1 = !!shouldShowOutboundPromotionOnPlatform2;
}
r0 = r1;
} else {
r0 = value2;
}
return r0;
}
function _fun58748() { // fn#58748, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1310, offset: 0x016d6213, size: 37 bytes, params: 1, frame: 11
const value = environment.__proto__.__proto__;
return (importDefault(7289) /* metro dependency 7289: PromotionsActionCreators */).markOutboundPromotionsSeen();
}
function _fun58750() { // fn#58750, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1396, offset: 0x016d6265, size: 72 bytes, params: 1, frame: 12
let value = environment.__proto__;
if (env1_2 && (lastFetchedActivePromotions == null || env1_1)) {
value = environment.__proto__.__proto__;
value = importDefault(7289) /* metro dependency 7289: PromotionsActionCreators */;
value.fetchActivePromotions();
}
}
function _fun58752() { // fn#58752, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1498, offset: 0x016d62da, size: 37 bytes, params: 1, frame: 11
const value = environment.__proto__.__proto__;
(importDefault(7289) /* metro dependency 7289: PromotionsActionCreators */).fetchClaimedOutboundPromotionCodes();
}
function _fun58756({promotion}) { // fn#58756, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1749, offset: 0x016d6379, size: 175 bytes, params: 2, frame: 14
var r0;
const binding = env0_0;
let value = binding.has(promotion.id);
if (value) {
r0 = !value;
} else {
value = environment.__proto__.__proto__;
value = require(7286) /* metro dependency 7286: PromotionUtils */;
value = value.isRecurringPromotion({promotionType: promotion.promotionType});
value = value === false;
r0 = value;
}
if (r0) {
value = environment.__proto__.__proto__;
value = require(7286) /* metro dependency 7286: PromotionUtils */;
value = !value.isLogitechPromotion(promotion);
r0 = value;
}
if (r0) {
value = environment.__proto__.__proto__;
value = require(7286) /* metro dependency 7286: PromotionUtils */;
value = value.shouldShowOutboundPromotionOnPlatform(promotion);
r0 = value;
}
return r0;
}