decord/source/modules/premium/gifting/GiftingBadgesUtils.tsx
github-actions ecf26fc058 chore: update source for alpha 347.2
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4823.js (118.4 MB)
2026-09-16 07:03:15 +00:00

122 lines
4.9 KiB
TypeScript

// Module ID: 10888
// Function ID: 10889
// Name: GiftingBadgesUtils
// Dependencies: [8321, 1372, 10884, 10889, 10890, 504, 4458, 1944, 2]
// Exports: getGiftingBadgeProgressPercent, getGiftingBadgeTierIconUrl, getIsGiftingBadgesDesktopEnabled, useIsEligibleToShowGiftingBadgeCoachmark, useIsGiftingBadgeComplexArtEnabled, useIsGiftingBadgesDesktopEnabled
// Module 10888 (GiftingBadgesUtils)
import initialize from "initialize" /* 504 */;
import DismissibleContentUnsafeUtils from "DismissibleContentUnsafeUtils" /* 4458 */;
import BadgeDirectoryStore from "BadgeDirectoryStore" /* 8321 */;
import GiftingBadgeExperiment2 from "GiftingBadgeExperiment" /* 10884 */;
import GiftingBadgeDesktopExperiment2 from "GiftingBadgeDesktopExperiment" /* 10889 */;
import GiftingBadgeComplexArtExperiment2 from "GiftingBadgeComplexArtExperiment" /* 10890 */;
import UserStore from "UserStore" /* 1372 */;
import size from "module_2" /* 2 */;
let closure_2 = BadgeDirectoryStore.getSingleRequirementThreshold;
let result = size.fileFinishedImporting("modules/premium/gifting/GiftingBadgesUtils.tsx");
export const getGiftingBadgeProgressPercent = function getGiftingBadgeProgressPercent(badgeProgress, currentTier, nextTier) {
const tmp = closure_2(currentTier);
const tmp2 = closure_2(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) {
const GiftingBadgeExperiment = GiftingBadgeExperiment2.GiftingBadgeExperiment;
const enabled = GiftingBadgeExperiment.useConfig({ location }).enabled;
const GiftingBadgeDesktopExperiment = GiftingBadgeDesktopExperiment2.GiftingBadgeDesktopExperiment;
let str = "-DISABLED";
if (enabled) {
str = "";
}
const obj = { location };
const obj2 = { location: "" + location + str };
return GiftingBadgeDesktopExperiment.useConfig({ location: "" + location + str }).enabled && enabled;
};
export const getIsGiftingBadgesDesktopEnabled = function getIsGiftingBadgesDesktopEnabled(location) {
const GiftingBadgeExperiment = GiftingBadgeExperiment2.GiftingBadgeExperiment;
let enabled = GiftingBadgeExperiment.getConfig({ location }).enabled;
if (enabled) {
const GiftingBadgeDesktopExperiment = GiftingBadgeDesktopExperiment2.GiftingBadgeDesktopExperiment;
const obj2 = { location };
enabled = GiftingBadgeDesktopExperiment.getConfig(obj2).enabled;
}
return enabled;
};
export const useIsGiftingBadgeComplexArtEnabled = function useIsGiftingBadgeComplexArtEnabled(UserSettingsGiftingBadgeProgress) {
const GiftingBadgeComplexArtExperiment = GiftingBadgeComplexArtExperiment2.GiftingBadgeComplexArtExperiment;
return GiftingBadgeComplexArtExperiment.useConfig({ location: UserSettingsGiftingBadgeProgress }).enabled;
};
export const getGiftingBadgeTierIconUrl = function getGiftingBadgeTierIconUrl(nextTier, isGiftingBadgeComplexArtEnabled) {
if (isGiftingBadgeComplexArtEnabled) {
let prop;
if (!tmp) {
prop = nextTier.complex_icon_static_url;
}
if (prop == null) {
let simple_icon_url1;
if (nextTier != null) {
simple_icon_url1 = nextTier.simple_icon_url;
}
prop = simple_icon_url1;
}
let simple_icon_url = prop;
} else if (!tmp) {
simple_icon_url = nextTier.simple_icon_url;
}
return simple_icon_url;
};
export const useIsEligibleToShowGiftingBadgeCoachmark = function useIsEligibleToShowGiftingBadgeCoachmark(location) {
const _location = location.location;
const GiftingBadgeExperiment = GiftingBadgeExperiment2.GiftingBadgeExperiment;
const enabled = GiftingBadgeExperiment.useConfig({ location: _location }).enabled;
const GiftingBadgeDesktopExperiment = GiftingBadgeDesktopExperiment2.GiftingBadgeDesktopExperiment;
let str = "-DISABLED";
if ("web" === location.platform) {
str = "";
}
let enabled2 = GiftingBadgeDesktopExperiment.useConfig({ location: "" + _location + str }).enabled;
let tmp4 = enabled;
if ("web" === location.platform) {
if (enabled2) {
enabled2 = enabled;
}
tmp4 = enabled2;
}
const obj = { location: "" + _location + str };
const items = [UserStore];
const stateFromStores = initialize.useStateFromStores(items, () => {
currentUser = currentUser.getCurrentUser();
let flag;
if (currentUser != null) {
flag = currentUser.hasHadPremium();
}
if (flag == null) {
flag = false;
}
return flag;
});
const tmpResult = initialize;
const result = DismissibleContentUnsafeUtils.useIsDismissibleContentDismissed_UNSAFE(tmp(1944).DismissibleContent.NEW_GIFTING_BADGES_COACHMARK);
if (tmp4) {
tmp4 = stateFromStores;
}
if (tmp4) {
tmp4 = !result;
}
return tmp4;
};