This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,155 @@
// Metro module 8112 (f8113).
import UserStore from "../../stores/UserStore";
import { Endpoints, ME } from "../../Constants";
import Dispatcher from "../../Dispatcher";
import { HTTP } from "../../_bundle/sendRequest";
import MonitoringAgent from "../monitoring/MonitoringAgent";
import { MetricEvents } from "../../_bundle/Module5872";
import SentryUtils_native from "../../utils/SentryUtils.native";
const urlUserId = function urlUserId(id2) {
return id2 === UserStore.getCurrentUser()?.id ? ME : id2;
};
export async function fetchBadgeDirectory(c26106_0, c26106_1) {
let id, c26106_5;
let c26106_6 = 0;
let c29890_1, c29890_0, c29890_2, c29890_3, c29890_4, c29890_5, c29890_6, c29890_7, c29890_8, c29890_9;
L17: {
try {
c29890_1 = void 0;
c29890_0 = c26106_0;
let r47 = c26106_1;
if (r47 === void 0) {
r47 = {};
}
c29890_1 = r47;
c29890_2 = void 0;
c29890_3 = void 0;
c29890_4 = void 0;
c29890_5 = void 0;
c29890_6 = void 0;
c29890_7 = void 0;
c29890_8 = void 0;
await void 0;
id = c29890_0;
if (id == null) {
id = UserStore.getCurrentUser()?.id;
}
c29890_2 = id;
if (c29890_2 != null) {
c29890_3 = UserStore.getCurrentUser()?.id;
c29890_4 = "viewed_user:" + (c29890_3 != null ? c29890_2 === c29890_3 ? "self" : "other" : "other");
c29890_5 = "attempt:" + (c29890_1.isRetry === true ? "retry" : "initial");
c29890_6 = Date.now();
Dispatcher.dispatch({
type: "BADGE_DIRECTORY_FETCH_START",
userId: c29890_2
});
c26106_6 = 1;
c29890_7 = (await HTTP.get({
url: Endpoints.USER_BADGES((0, urlUserId)(c29890_2)),
rejectWithError: true
})).body;
c29890_8 = [c29890_4, "result:success", "catalog_state:" + (c29890_7.badges.length === 0 ? "empty" : "non_empty"), c29890_5];
MonitoringAgent.distribution({
name: MetricEvents.BADGE_DIRECTORY_CATALOG_FETCH,
tags: c29890_8
}, Date.now() - c29890_6);
Dispatcher.dispatch({
type: "BADGE_DIRECTORY_FETCH_SUCCESS",
userId: c29890_2,
badges: c29890_7.badges
});
c26106_6 = 0;
}
} catch ($e) {
const r44 = $e;
let r8 = r44;
c26106_5 = r44;
if (c26106_6 !== 0) {
while (true) {
try {
const r211 = c26106_5;
c26106_6 = 0;
c29890_9 = r211;
MonitoringAgent.distribution({
name: MetricEvents.BADGE_DIRECTORY_CATALOG_FETCH,
tags: [c29890_4, "result:failure", "catalog_state:unknown", c29890_5]
}, Date.now() - c29890_6);
Dispatcher.dispatch({
type: "BADGE_DIRECTORY_FETCH_FAILURE",
userId: c29890_2
});
SentryUtils_native.captureException(c29890_9);
break L17;
} catch (r207) {
r8 = r207;
c26106_5 = r207;
if (c26106_6 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export async function fetchBadge(c26107_0, c26107_1) {
let id2, c26107_5;
let c26107_6 = 0;
let c29891_0, c29891_1, c29891_2;
L17: {
try {
c29891_0 = void 0;
c29891_1 = void 0;
id2 = c26107_1;
if (c26107_1 == null) {
id2 = UserStore.getCurrentUser()?.id;
}
c29891_0 = id2;
if (id2 != null) {
c26107_6 = 1;
c29891_1 = await HTTP.get({
url: Endpoints.USER_BADGE(urlUserId(id2), c26107_0),
rejectWithError: true
});
Dispatcher.dispatch({
type: "BADGE_FETCH_SUCCESS",
userId: c29891_0,
badge: c29891_1.body
});
c26107_6 = 0;
break L17;
}
} catch ($e) {
const r29 = $e;
let r8 = r29;
c26107_5 = r29;
if (c26107_6 !== 0) {
while (true) {
try {
const r83 = c26107_5;
c26107_6 = 0;
c29891_2 = r83;
SentryUtils_native.captureException(c29891_2);
break L17;
} catch (r79) {
r8 = r79;
c26107_5 = r79;
if (c26107_6 === 0) {
break;
}
}
}
}
throw r8;
}
return void 0;
}
}
export function markBadgeDirectoryBadgeIndicatorSeen(a0) {
Dispatcher.dispatch({
type: "BADGE_DIRECTORY_MARK_BADGE_INDICATOR_SEEN",
badgeId: a0
});
}
+226
View File
@@ -0,0 +1,226 @@
// Metro module 8109 (f8110).
import UserStore from "../../stores/UserStore";
import Durations from "../../utils/Durations";
import { resolveProfileBadgeId } from "./BadgeIdResolution";
import Backoff from "../../_bundle/Backoff";
import { fetchBadgeDirectory } from "./BadgeDirectoryActionCreators";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
const HOUR = Durations.Millis.HOUR;
let c5146_5 = new Map();
let c5146_6 = new Set();
let c5146_7 = new Set();
let c5146_8 = new Map();
let c5146_9 = new Map();
let c5146_10 = new Map();
class BadgeDirectoryStore extends Module589.Store {
static displayName = "BadgeDirectoryStore";
initialize() {
this.waitFor(UserStore);
}
getBadges(a0) {
const r4 = a0 == null ? UserStore.getCurrentUser()?.id : a0;
if (r4 == null) {
return [];
}
const r6 = c5146_5.get(r4);
return r6 != null ? Array.from(r6.values()) : [];
}
hasCatalogFor(a0) {
return c5146_6.has(a0);
}
isCatalogStaleFor(a0) {
const r6 = c5146_8.get(a0);
return r6 == null || Date.now() - r6 >= HOUR;
}
hasCatalogFetchErrorFor(a0) {
const r5 = a0 == null ? UserStore.getCurrentUser()?.id : a0;
return r5 != null && c5146_7.has(r5);
}
getBadgeById(a0, a1) {
const r6 = a1 == null ? UserStore.getCurrentUser()?.id : a1;
const r9 = r6 != null;
let r10 = void 0;
if (r9) {
const r12 = c5146_5.get(r6);
r10 = r12 == null ? void 0 : r12.get(a0);
}
return r10;
}
getSingleRequirementProgress(a0, a1) {
const progress = this.getBadgeById(a0, a1)?.progress;
if (progress != null && progress.length !== 0) {
return progress[0];
}
}
getCurrentTier(a0, a1) {
const badgeById = this.getBadgeById(a0, a1);
if (badgeById?.current_tier != null) {
return badgeById.tiers.find((tier) => tier.key === badgeById.current_tier);
}
}
getObtainedAt(a0, a1) {
const badgeById3 = this.getBadgeById(a0, a1);
const r1 = badgeById3 != null;
let r9 = void 0;
if (r1) {
const r11 = badgeById3.current_tier != null;
let r12 = void 0;
if (r11) {
const tier_obtained_at = badgeById3.tier_obtained_at;
r12 = tier_obtained_at == null ? void 0 : tier_obtained_at[badgeById3.current_tier];
}
if (r12 == null) {
r12 = badgeById3.obtained_at;
}
r9 = r12;
}
return r9;
}
getNextTier(a0, a1) {
const badgeById2 = this.getBadgeById(a0, a1);
if (badgeById2?.next_tier != null) {
return badgeById2.tiers.find((tier) => tier.key === badgeById2.next_tier);
}
}
getRemainingToNextTier(a0, a1) {
const nextTier = this.getNextTier(a0, a1);
const singleRequirementProgress = this.getSingleRequirementProgress(a0, a1);
const r2 = nextTier == null;
let r12 = 0;
if (!r2) {
const r13 = singleRequirementProgress == null;
r12 = 0;
if (!r13) {
const r15 = Math;
let r8 = nextTier == null ? void 0 : nextTier.requirements[0]?.threshold;
if (r8 == null) {
r8 = 0;
}
r12 = r15.max(0, r8 - singleRequirementProgress.current);
}
}
return r12;
}
}
const badgeDirectoryStore = new BadgeDirectoryStore(Dispatcher, {
BADGE_DIRECTORY_FETCH_START: function handleFetchStart({ userId }) {
const set = new Set(c5146_7);
c5146_7 = set;
set.delete(userId);
},
BADGE_DIRECTORY_FETCH_SUCCESS: function handleFetchSuccess({ userId, badges }) {
const map = new Map(c5146_5);
map.set(userId, new Map(badges.map((badge) => [badge.badge_id, badge])));
c5146_5 = map;
c5146_6 = new Set(c5146_6).add(userId);
const set = new Set(c5146_7);
c5146_7 = set;
set.delete(userId);
c5146_8 = new Map(c5146_8).set(userId, Date.now());
},
BADGE_DIRECTORY_FETCH_FAILURE: function handleFetchFailure({ userId }) {
c5146_7 = new Set(c5146_7).add(userId);
},
BADGE_FETCH_SUCCESS: function handleBadgeFetchSuccess({ userId, badge }) {
const map = new Map(c5146_5);
let r15 = map.get(userId);
if (r15 == null) {
r15 = new Map();
}
const map2 = new Map(r15);
map2.set(badge.badge_id, badge);
map.set(userId, map2);
c5146_5 = map;
},
USER_PROFILE_FETCH_SUCCESS: function handleUserProfileFetchSuccess({ userProfile }) {
let r24;
const id = userProfile.user.id;
if (c5146_6.has(id)) {
let badges = userProfile.badges;
if (badges == null) {
badges = [];
}
const length = badges.filter((badge) => resolveProfileBadgeId(badge.id) != null).length;
let r33 = 0;
const r35 = c5146_5.get(id);
let r9 = r35 == null ? void 0 : r35.values();
if (r9 == null) {
r9 = [];
}
let r39 = r9[Symbol.iterator]();
const next = r39.next;
while (true) {
const r42 = r39 === void 0 ? void 0 : (r24 = next.call(r39)).done ? r39 = void 0 : r24.value;
if (r39 === void 0) {
if (length !== r33) {
let r56 = c5146_10.get(id);
if (r56 == null) {
r56 = 0;
}
if (!(Date.now() >= r56)) {
break;
}
let r63 = c5146_9.get(id);
if (r63 == null) {
r63 = new Backoff(Durations.Millis.MINUTE, HOUR, true);
}
c5146_9.set(id, r63);
c5146_10.set(id, Date.now() + r63.fail());
fetchBadgeDirectory(id);
break;
}
const r48 = c5146_9.get(id);
if (r48 != null) {
r48.succeed();
}
c5146_10.delete(id);
break;
}
try {
if (r42.owned) {
r33 = r33 + 1;
}
} catch (r45) {
if (r39 !== void 0 && typeof r39.return === "function") {
try {
r39.return();
} catch {}
}
throw r45;
}
}
}
return false;
},
LOGOUT: function handleReset() {
c5146_5 = new Map();
c5146_6 = new Set();
c5146_7 = new Set();
c5146_8 = new Map();
c5146_9.clear();
c5146_10.clear();
}
});
export default badgeDirectoryStore;
export function getSingleRequirementThreshold(a0) {
let r4 = a0 == null ? void 0 : a0.requirements[0]?.threshold;
if (r4 == null) {
r4 = 0;
}
return r4;
}
export function getObtainedAtFromBadge(a0) {
if (a0 != null) {
const r7 = a0.current_tier != null;
let r8 = void 0;
if (r7) {
const tier_obtained_at = a0.tier_obtained_at;
r8 = tier_obtained_at == null ? void 0 : tier_obtained_at[a0.current_tier];
}
if (r8 == null) {
r8 = a0.obtained_at;
}
return r8;
}
}
+18
View File
@@ -0,0 +1,18 @@
// Metro module 8110 (f8111).
import { LEGACY_BADGE_ID_MAP } from "../../_bundle/Module8111";
import { BadgeId } from "../../_bundle/Module8106";
let c5147_2 = new Set(Object.values(LEGACY_BADGE_ID_MAP));
export function legacyBadgeIdToBadgeId(a0) {
return LEGACY_BADGE_ID_MAP[a0];
}
export function resolveProfileBadgeId(a0) {
const r9 = LEGACY_BADGE_ID_MAP[a0];
if (r9 != null) {
return r9;
}
const r15 = BadgeId[a0.toUpperCase()];
return typeof r15 === "number" ? r15 : void 0;
}
export function isLegacyBadgeId(a0) {
return c5147_2.has(a0);
}