decord/source/modules/premium/gifting/GiftingBadgesUtils.tsx

99 lines
3.5 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 13059
// Function ID: 13060
2026-07-20 16:05:17 +00:00
// Name: getGiftingBadgeProgressPercent
2026-08-24 06:08:38 +00:00
// Dependencies: [8973, 1922, 9629, 13060, 589, 4200, 1377, 2]
2026-07-20 16:05:17 +00:00
// Exports: getGiftingBadgeProgressPercent, getIsGiftingBadgesDesktopEnabled, useIsEligibleToShowGiftingBadgeCoachmark, useIsGiftingBadgesDesktopEnabled
2026-08-24 06:08:38 +00:00
// Module 13059 (getGiftingBadgeProgressPercent)
import set from "set" /* 2 */;
import initialize from "initialize" /* 8973 */;
import apexExperiment from "apexExperiment" /* 9629 */;
import apexExperiment2 from "apexExperiment" /* 13060 */;
import closure_3 from "mergeGuildAvatar" /* 1922 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
let closure_2 = initialize.getSingleRequirementThreshold;
let result = set.fileFinishedImporting("modules/premium/gifting/GiftingBadgesUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getGiftingBadgeProgressPercent = function getGiftingBadgeProgressPercent(badgeProgress, currentTier, nextTier) {
const tmp = callback(currentTier);
const tmp2 = callback(nextTier);
if (null != nextTier) {
let num6 = 100;
if (tmp2 > 0) {
num6 = badgeProgress / tmp2 * 100;
}
let num3 = num6;
} else {
num3 = 100;
if (tmp > 0) {
const _Math = Math;
num3 = Math.min(tmp, badgeProgress) / tmp * 100;
}
}
return Math.min(Math.max(num3, 0), 100);
};
export const useIsGiftingBadgesDesktopEnabled = function useIsGiftingBadgesDesktopEnabled(location) {
2026-08-24 06:08:38 +00:00
const GiftingBadgeExperiment = apexExperiment.GiftingBadgeExperiment;
2026-07-20 16:05:17 +00:00
let obj = { location };
const enabled = GiftingBadgeExperiment.useConfig(obj).enabled;
2026-08-24 06:08:38 +00:00
const GiftingBadgeDesktopExperiment = apexExperiment2.GiftingBadgeDesktopExperiment;
2026-07-20 16:05:17 +00:00
let str = "-DISABLED";
if (enabled) {
str = "";
}
2026-07-29 08:29:29 +00:00
obj = { location: "" + location + str };
2026-07-20 16:05:17 +00:00
return GiftingBadgeDesktopExperiment.useConfig(obj).enabled && enabled;
};
export const getIsGiftingBadgesDesktopEnabled = function getIsGiftingBadgesDesktopEnabled(location) {
2026-08-24 06:08:38 +00:00
const GiftingBadgeExperiment = apexExperiment.GiftingBadgeExperiment;
2026-07-20 16:05:17 +00:00
let obj = { location };
2026-07-29 08:29:29 +00:00
let enabled = GiftingBadgeExperiment.getConfig(obj).enabled;
if (enabled) {
2026-08-24 06:08:38 +00:00
const GiftingBadgeDesktopExperiment = apexExperiment2.GiftingBadgeDesktopExperiment;
2026-07-29 08:29:29 +00:00
obj = { location: null };
obj[0] = location;
2026-07-20 16:05:17 +00:00
enabled = GiftingBadgeDesktopExperiment.getConfig(obj).enabled;
}
return enabled;
};
export const useIsEligibleToShowGiftingBadgeCoachmark = function useIsEligibleToShowGiftingBadgeCoachmark(location) {
const _location = location.location;
2026-08-24 06:08:38 +00:00
const GiftingBadgeExperiment = apexExperiment.GiftingBadgeExperiment;
2026-07-20 16:05:17 +00:00
const enabled = GiftingBadgeExperiment.useConfig({ location: _location }).enabled;
2026-08-24 06:08:38 +00:00
const GiftingBadgeDesktopExperiment = apexExperiment2.GiftingBadgeDesktopExperiment;
2026-07-20 16:05:17 +00:00
let str = "-DISABLED";
if ("web" === location.platform) {
str = "";
}
2026-07-29 08:29:29 +00:00
let enabled2 = GiftingBadgeDesktopExperiment.useConfig({ location: "" + _location + str }).enabled;
let tmp4 = enabled;
2026-07-20 16:05:17 +00:00
if ("web" === location.platform) {
if (enabled2) {
enabled2 = enabled;
}
2026-07-29 08:29:29 +00:00
tmp4 = enabled2;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmpResult = tmp(589);
2026-08-24 06:08:38 +00:00
const items = [closure_3];
2026-07-29 08:29:29 +00:00
const stateFromStores = tmpResult.useStateFromStores(items, () => {
currentUser = currentUser.getCurrentUser();
let flag;
if (currentUser != null) {
flag = currentUser.hasHadPremium();
}
if (flag == null) {
flag = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return flag;
2026-07-20 16:05:17 +00:00
});
2026-08-24 06:08:38 +00:00
tmpResult = tmp(4200);
2026-08-11 06:20:06 +00:00
const result = tmpResult.useIsDismissibleContentDismissed_UNSAFE(tmp(1377).DismissibleContent.NEW_GIFTING_BADGES_COACHMARK);
2026-07-29 08:29:29 +00:00
if (tmp4) {
tmp4 = stateFromStores;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp4) {
tmp4 = !result;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp4;
2026-07-20 16:05:17 +00:00
};