decord/source/modules/badges/BadgeUtils.tsx

82 lines
2.5 KiB
TypeScript
Raw Normal View History

// Module ID: 11332
// Function ID: 11333
// Name: BadgeUtils
// Dependencies: [8300, 8301, 8310, 2]
2026-08-26 06:04:24 +00:00
// Exports: getLegacyIconUrlByBadgeId, getUnhideableBadgeIds, groupCustomizableBadges
2026-08-25 06:04:03 +00:00
// Module 11332 (BadgeUtils)
import Constants from "Constants" /* 8300 */;
import BadgeId from "BadgeId" /* 8301 */;
import BadgeIdResolution from "BadgeIdResolution" /* 8310 */;
import size from "module_2" /* 2 */;
2026-08-25 06:04:03 +00:00
2026-08-28 06:19:39 +00:00
function isPinnedBadge(badge_id) {
return badge_id === BadgeId.BadgeId.STAFF;
}
2026-08-25 06:04:03 +00:00
function getProfileBadgeIconUrl(iconSrc) {
iconSrc = iconSrc.iconSrc;
if (iconSrc == null) {
iconSrc = getBadgeAssetFromCDN(iconSrc.icon);
}
return iconSrc;
}
const getBadgeAssetFromCDN = Constants.getBadgeAssetFromCDN;
let result = size.fileFinishedImporting("modules/badges/BadgeUtils.tsx");
2026-08-25 06:04:03 +00:00
export const MAX_DISPLAYED_PROFILE_BADGES = 6;
2026-08-28 06:19:39 +00:00
export { isPinnedBadge };
2026-08-25 06:04:03 +00:00
export const getUnhideableBadgeIds = function getUnhideableBadgeIds(tenureBadgeHideable) {
const _Set = Set;
2026-08-28 06:19:39 +00:00
const STAFF = BadgeId.BadgeId.STAFF;
if (tenureBadgeHideable.tenureBadgeHideable) {
const items = [STAFF];
let _Set1 = new _Set(items);
2026-08-28 06:19:39 +00:00
} else {
const items1 = [STAFF, BadgeId.BadgeId.PREMIUM_TENURE];
_Set1 = new _Set(items1);
2026-08-25 06:04:03 +00:00
}
return _Set1;
2026-08-25 06:04:03 +00:00
};
2026-08-26 06:04:24 +00:00
export const groupCustomizableBadges = function groupCustomizableBadges(memo) {
const fixedBadges = [];
const reorderableBadges = [];
const hiddenBadges = [];
const iter = memo[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
if (nextResult.owned) {
2026-08-28 06:19:39 +00:00
if (isPinnedBadge(tmp2.badge_id)) {
2026-08-26 06:04:24 +00:00
let arr = fixedBadges.push(tmp2);
} else if (tmp2.hidden) {
let arr2 = hiddenBadges.push(tmp2);
2026-08-26 06:04:24 +00:00
} else {
let arr3 = reorderableBadges.push(tmp2);
2026-08-26 06:04:24 +00:00
}
2026-08-25 06:04:03 +00:00
}
2026-08-26 06:04:24 +00:00
continue;
}
return { fixedBadges, reorderableBadges, hiddenBadges };
2026-08-25 06:04:03 +00:00
};
export { getProfileBadgeIconUrl };
export const getLegacyIconUrlByBadgeId = function getLegacyIconUrlByBadgeId(badges) {
const map = new Map();
const iter = badges[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
let obj2 = BadgeIdResolution;
2026-08-25 06:04:03 +00:00
let profileBadgeId = obj2.resolveProfileBadgeId(nextResult.id);
let tmp6 = profileBadgeId;
let hasItem = null == profileBadgeId;
if (!hasItem) {
hasItem = map.has(tmp6);
}
if (!hasItem) {
let result = map.set(tmp6, getProfileBadgeIconUrl(tmp2));
}
continue;
}
return map;
};