Files
discord-decomp/sources/modules/badges/BadgeDirectoryStore.tsx
T
2026-07-28 01:06:53 +03:00

305 lines
14 KiB
TypeScript

/* Metro module 7670; source: modules/badges/BadgeDirectoryStore.tsx; dependencies: [6, 7, 15, 17, 18, 1878, 566, 694, 2] */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
function _fun61260(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#61260, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:6, offset: 0x01b39c7b, size: 445 bytes, params: 8, frame: 21
const closure = function(a0) {
return (a0 == null || a0.requirements[0] == null ? undefined : a0.requirements[0].threshold) ?? 0;
};
const closure2 = function(a0) {
var r0;
var value;
if (a0 != null) {
value = undefined;
r0 = a0.current_tier != null ? a0.tier_obtained_at == null ? value : a0.tier_obtained_at[a0.current_tier] : value;
r0 = r0 ?? a0.obtained_at;
return r0;
}
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const Map = global.Map;
const map = new Map();
let Set = global.Set;
let set = new Set();
Set = global.Set;
set = new Set();
const Store = (Flux).Store;
_fun61266(Store).displayName = 'BadgeDirectoryStore';
set = new set(importDefault(694) /* metro dependency 694: Dispatcher */,
{BADGE_DIRECTORY_FETCH_START: BADGE_DIRECTORY_FETCH_START,
BADGE_DIRECTORY_FETCH_SUCCESS: BADGE_DIRECTORY_FETCH_SUCCESS,
BADGE_DIRECTORY_FETCH_FAILURE: BADGE_DIRECTORY_FETCH_FAILURE, BADGE_FETCH_SUCCESS: BADGE_FETCH_SUCCESS,
LOGOUT: function() {
env0_6 = new global.Map();
env0_7 = new global.Set();
env0_8 = new global.Set();
}});
(FileImportTrackerModule).fileFinishedImporting('modules/badges/BadgeDirectoryStore.tsx');
exports.default = set;
exports.getSingleRequirementThreshold = closure;
exports.getObtainedAtFromBadge = closure2;
function _isNativeReflectConstruct_61261() { // fn#61261, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:158, offset: 0x01b39e38, size: 94 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_61261_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun61266(a0) { // fn#61266, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:691, offset: 0x01b39f17, size: 281 bytes, params: 2, frame: 16
const BadgeDirectoryStore2 = BadgeDirectoryStore;
Inherits(BadgeDirectoryStore2, a0);
return CreateClass(BadgeDirectoryStore2, [{key: 'initialize', value: function() {
this.waitFor(UserStore);
}}, {key: 'getBadges', value: value_61269}, {key: 'hasCatalogFor', value: value_61270},
{key: 'hasCatalogFetchErrorFor', value: value_61271}, {key: 'getBadgeById', value: value_61272},
{key: 'getSingleRequirementProgress', value: function(a0, a1) {
var r1;
var value = this.getBadgeById(a0, a1);
var value2 = undefined;
r1 = value == null ? value2 : value.progress;
if (r1 != null) {
if (r1.length !== 0) {
return r1[0];
}
}
return value2;
}}, {key: 'getCurrentTier', value: function(a0, a1) {
var value = this.getBadgeById(a0, a1);
var env0_0 = value;
var value2 = undefined;
if ((value == null ? value2 : value.current_tier) != null) {
return value.tiers.find(_fun61275);
}
return value2;
}}, {key: 'getObtainedAt', value: value_61276}, {key: 'getNextTier', value: function(a0, a1) {
var value = this.getBadgeById(a0, a1);
var env0_0 = value;
var value2 = undefined;
if ((value == null ? value2 : value.next_tier) != null) {
return value.tiers.find(_fun61278);
}
return value2;
}}, {key: 'getRemainingToNextTier', value: value_61279}]);
function BadgeDirectoryStore() { // fn#61267, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:703, offset: 0x00fbdfd6, size: 113 bytes, params: 1, frame: 20
const value = environment.__proto__;
env1_0(this, BadgeDirectoryStore);
const value3 = env1_3(BadgeDirectoryStore);
return env1_2(this, _isNativeReflectConstruct_61261() ? global.Reflect.construct(value3, arguments,
env1_3(this).constructor) : value3.apply(this, arguments));
}
function value_61269(a0) { // fn#61269, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:1068, offset: 0x01b3a030, size: 108 bytes, params: 2, frame: 13
var r3;
let value = a0;
if (value != null) {
r3 = value;
} else {
value = environment.__proto__;
value = UserStore.getCurrentUser();
r3 = value?.id;
}
if (r3 == null) {
return [];
}
value = environment.__proto__;
value = env1_6.get(r3);
return value != null ? global.Array.from(value.values()) : [];
}
function value_61270(a0) { // fn#61270, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:1244, offset: 0x010e8036, size: 22 bytes, params: 2, frame: 11
return env1_7.has(a0);
}
function value_61271(a0) { // fn#61271, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:1311, offset: 0x01b3a09c, size: 68 bytes, params: 2, frame: 13
var r3;
var r0;
let value = a0;
if (value != null) {
r3 = value;
} else {
value = environment.__proto__;
value = UserStore.getCurrentUser();
r3 = value?.id;
}
value = r3 != null;
if (value) {
value = environment.__proto__;
value = env1_8.has(r3);
r0 = value;
} else {
r0 = value;
}
return r0;
}
function value_61272(a0, a1) { // fn#61272, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:1435, offset: 0x01b3a0e0, size: 95 bytes, params: 3, frame: 14
var r5;
var r0;
var value3;
var value4;
let value = a1;
if (value != null) {
r5 = value;
} else {
value = environment.__proto__;
value = UserStore.getCurrentUser();
r5 = value?.id;
}
value = undefined;
if (r5 != null) {
value3 = environment.__proto__;
value4 = env1_6.get(r5);
r0 = value4 == null ? value : value4.get(a0);
} else {
r0 = value;
}
return r0;
}
function value_61274(a0, a1) { // fn#61274, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:1751, offset: 0x01b3a17e, size: 76 bytes, params: 3, frame: 15
const badgeById = this.getBadgeById(a0, a1);
const value2 = undefined;
if ((badgeById == null ? value2 : badgeById.current_tier) != null) {
return badgeById.tiers.find(_fun61275);
}
return value2;
function _fun61275({key}) { // fn#61275, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:1856, offset: 0x01b3a1ca, size: 27 bytes, params: 2, frame: 2
return key === ClassCallCheck.current_tier;
}
}
function value_61276(a0, a1) { // fn#61276, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:1913, offset: 0x01b3a1e5, size: 37 bytes, params: 3, frame: 14
const value = environment.__proto__;
return getObtainedAtFromBadge(this.getBadgeById(a0, a1));
}
function value_61277(a0, a1) { // fn#61277, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:2008, offset: 0x01b3a20a, size: 76 bytes, params: 3, frame: 15
const badgeById = this.getBadgeById(a0, a1);
const value2 = undefined;
if ((badgeById == null ? value2 : badgeById.next_tier) != null) {
return badgeById.tiers.find(_fun61278);
}
return value2;
function _fun61278({key}) { // fn#61278, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:2110, offset: 0x01b3a256, size: 27 bytes, params: 2, frame: 2
return key === ClassCallCheck.next_tier;
}
}
function value_61279(a0, a1) { // fn#61279, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:2173, offset: 0x01b3a271, size: 99 bytes, params: 3, frame: 17
var r0;
var Math;
var max;
var value4;
let value = this.getNextTier(a0, a1);
const singleRequirementProgress = this.getSingleRequirementProgress(a0, a1);
const value3 = 0;
if (value == null) {
r0 = value3;
} else if (singleRequirementProgress == null) {
r0 = value3;
} else {
Math = global.Math;
max = Math.max;
value4 = environment.__proto__;
value = getSingleRequirementThreshold(value);
value = Reflect.apply(max, Math, [value3, value - singleRequirementProgress.current]);
r0 = value;
}
return r0;
}
}
function BADGE_DIRECTORY_FETCH_START({userId}) { // fn#61280, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:2442, offset: 0x01b3a2d4, size: 61 bytes, params: 2, frame: 13
const Set = global.Set;
const binding = env0_8;
const value2 = Object.create(Set.prototype, {constructor: {value: Set}});
const set = new Set(binding);
(set instanceof Object ? set : value2).delete(userId);
}
function BADGE_DIRECTORY_FETCH_SUCCESS({userId, badges}) { // fn#61281, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:2536, offset: 0x01b3a311, size: 199 bytes, params: 2, frame: 18
let Map = global.Map;
let binding = env0_6;
let map = new Map(binding);
let set = map.set;
Map = global.Map;
const value4 = badges.map(function(a0) {
return [a0.badge_id, a0];
});
const value5 = Object.create(Map.prototype, {constructor: {value: Map}});
map = new Map(value4);
Reflect.apply(set, map, [userId, map instanceof Object ? map : value5]);
let Set = global.Set;
binding = env0_7;
const value7 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set(binding);
env0_7 = (set instanceof Object ? set : value7).add(userId);
Set = global.Set;
binding = env0_8;
const value9 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set(binding);
(set instanceof Object ? set : value9).delete(userId);
}
function BADGE_DIRECTORY_FETCH_FAILURE({userId}) { // fn#61283, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:2727, offset: 0x01b3a3ef, size: 61 bytes, params: 2, frame: 13
const Set = global.Set;
const binding = env0_8;
const value2 = Object.create(Set.prototype, {constructor: {value: Set}});
const set = new Set(binding);
env0_8 = (set instanceof Object ? set : value2).add(userId);
}
function BADGE_FETCH_SUCCESS({userId, badge}) { // fn#61284, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7848:2808, offset: 0x01b3a42c, size: 156 bytes, params: 2, frame: 17
var r5;
let Map = global.Map;
let map = new Map(env0_6);
const value4 = map.get(userId);
if (value4 != null) {
r5 = value4;
} else {
map = new global.Map();
}
Map = global.Map;
map = new Map();
map.set(badge.badge_id, badge);
map.set(userId, map);
}
}
global.__d(_fun61260, 7670, [6, 7, 15, 17, 18, 1878, 566, 694,
2]) /* metro module 7670, dependencies: [6, 7, 15, 17, 18, 1878, 566, 694, 2] */;