decord/alpha/source/modules/badges/BadgeUtils.tsx
github-actions 6eea20b8e1 chore: update source for alpha 348.3
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5014.js (118.4 MB)
2026-09-24 10:59:02 +00:00

149 lines
4.4 KiB
TypeScript

// Module ID: 11550
// Function ID: 11551
// Name: BadgeUtils
// Dependencies: [8531, 8532, 1115, 8541, 2010, 2]
// Exports: getAlwaysVisibleCopy, getDirectoryBadges, getLegacyDescriptionByBadgeId, getLegacyIconUrlByBadgeId, getProfileBadgeLabel, getUnhideableBadgeIds, groupCustomizableBadges
// Module 11550 (BadgeUtils)
import StringUtils from "StringUtils" /* 2010 */;
import Constants from "Constants" /* 8531 */;
import BadgeId from "BadgeId" /* 8532 */;
import BadgeIdResolution from "BadgeIdResolution" /* 8541 */;
import size from "module_2" /* 2 */;
function isPinnedBadge(badge_id) {
return badge_id === BadgeId.BadgeId.STAFF;
}
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");
export const MAX_DISPLAYED_PROFILE_BADGES = 6;
export { isPinnedBadge };
export const getAlwaysVisibleCopy = function getAlwaysVisibleCopy(badge_id) {
if (badge_id === BadgeId.BadgeId.STAFF) {
let nPQVxb = tmp(1115).t.t3udZb;
} else {
nPQVxb = tmp(1115).t.nPQVxb;
}
return nPQVxb;
};
export const getDirectoryBadges = function getDirectoryBadges(stateFromStoresArray) {
const earnable = [];
const owned = [];
const iter = stateFromStoresArray[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
if (nextResult.owned) {
let arr = owned.push(tmp2);
} else if (tmp2.is_earnable) {
let arr2 = earnable.push(tmp2);
}
continue;
}
return { earnable, owned };
};
export const getUnhideableBadgeIds = function getUnhideableBadgeIds(tenureBadgeHideable) {
const _Set = Set;
const STAFF = BadgeId.BadgeId.STAFF;
if (tenureBadgeHideable.tenureBadgeHideable) {
const items = [STAFF];
let _Set1 = new _Set(items);
} else {
const items1 = [STAFF, BadgeId.BadgeId.PREMIUM_TENURE];
_Set1 = new _Set(items1);
}
return _Set1;
};
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) {
if (isPinnedBadge(tmp2.badge_id)) {
let arr = fixedBadges.push(tmp2);
} else if (tmp2.hidden) {
let arr2 = hiddenBadges.push(tmp2);
} else {
let arr3 = reorderableBadges.push(tmp2);
}
}
continue;
}
return { fixedBadges, reorderableBadges, hiddenBadges };
};
export { getProfileBadgeIconUrl };
export const getProfileBadgeLabel = function getProfileBadgeLabel(description, info_label) {
if (info_label != null) {
info_label = info_label.info_label;
}
if (null != info_label) {
if (!obj.isLegacyBadgeId(info_label.badge_id)) {
const tmpResult = StringUtils;
}
return info_label;
}
let str = description;
if (description == null) {
let name;
if (info_label != null) {
name = info_label.name;
}
str = name;
}
if (str == null) {
str = "";
}
info_label = str;
};
export const getLegacyDescriptionByBadgeId = function getLegacyDescriptionByBadgeId(badges) {
const map = new Map();
const iter = badges[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
let obj2 = BadgeIdResolution;
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, tmp2.description);
}
continue;
}
return map;
};
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;
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;
};