Files
discord-decomp/sources/modules/user_profile/UserProfileStore.tsx
T
2026-07-27 16:20:00 +03:00

1150 lines
48 KiB
TypeScript

/* Metro module 5189; source: modules/user_profile/UserProfileStore.tsx; dependencies: [6, 7, 15, 17, 18, 1949, 1885, 1226, 1867, 1228, 4396, 4896, 661, 5190, 22, 5191, 5210, 4041, 1904, 5211, 1244, 5212, 4915, 1360, 5213, 2] */
function _fun45704(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#45704, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:6, offset: 0x01195ca2, size: 890 bytes, params: 8, frame: 20
const env0_0 = require;
const _arrayLikeToArray_45710 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const handleProfileUpdateStart = function() {
env0_28 = true;
};
const handleProfileUpdateFailure = function() {
env0_28 = false;
};
const handleGuildMemberStatusChange = function(a0) {
return resetProfileFetch(a0.user.id);
};
const handleRelationshipStatusChange = function(a0) {
return resetProfileFetch(a0.relationship.id);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(6) /* metro dependency 6 */;
const env0_4 = importDefault(7) /* metro dependency 7 */;
const env0_5 = importDefault(15) /* metro dependency 15 */;
const env0_6 = importDefault(17) /* metro dependency 17 */;
const env0_7 = importDefault(18) /* metro dependency 18 */;
const localeStore = importDefault(1949) /* metro dependency 1949: LocaleStore */;
const userRecord = importDefault(1885) /* metro dependency 1885: UserRecord */;
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
let value = importDefault(1228) /* metro dependency 1228: MobileCacheSnapshotStore */;
const presenceStore = importDefault(4396) /* metro dependency 4396: PresenceStore */;
const sortedGuildStore = importDefault(4896) /* metro dependency 4896: SortedGuildStore */;
const env0_14 = (require(661) /* metro dependency 661: Constants */).MAX_TIMEOUT_MS;
const Symbol = global.Symbol;
const env0_15 = Symbol('NO GUILD ID');
let Map = global.Map;
let map = new Map();
const Set = global.Set;
const set = new Set();
Map = global.Map;
map = new Map();
Map = global.Map;
map = new Map();
const env0_20 = {};
Map = global.Map;
map = new Map();
Map = global.Map;
map = new Map();
Map = global.Map;
map = new Map();
const env0_24 = [];
const env0_25 = [];
Map = global.Map;
map = new Map();
value = _fun45750(value);
value.displayName = 'UserProfileStore';
value.LATEST_SNAPSHOT_VERSION = 1;
value = new value();
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/user_profile/UserProfileStore.tsx');
exports.default = value;
}
function _isNativeReflectConstruct_45705() { // fn#45705, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:249, offset: 0x0119601c, 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_45705_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _createForOfIteratorHelperLoose_45708(a0, a1) { // fn#45708, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:442, offset: 0x0119607a, size: 370 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun45709;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_45710(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_45710(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_45710(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun45709;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
}
function createUserWidgetFromServer(a0) { // fn#45711, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:1482, offset: 0x011961ec, size: 405 bytes, params: 2, frame: 18
var ApplicationWidget;
var object2;
var applicationWidget;
var value3;
const BaseGameWidget = (require(5191) /* metro dependency 5191: UserProfileGameWidgetTypes */).BaseGameWidget;
var baseGameWidget;
const type = a0.data.type;
var value;
const WidgetType = (require(5190) /* metro dependency 5190: WidgetType */).WidgetType;
const CURRENT_GAMES = WidgetType.CURRENT_GAMES;
if (CURRENT_GAMES === type) {
value3 = (importDefault(22) /* metro dependency 22 */).uniqBy(a0.data.games.map(function(a0) {
return {applicationId: a0.game_id, comment: a0.comment, tags: a0.tags};
}), 'applicationId');
object2 = {};
object2.id = a0.id;
object2.type = type;
object2.games = value3;
value = Object.create(BaseGameWidget.prototype, {constructor: {value: BaseGameWidget}});
baseGameWidget = new BaseGameWidget();
return baseGameWidget instanceof Object ? baseGameWidget : value;
}
const FAVORITE_GAMES = WidgetType.FAVORITE_GAMES;
if (FAVORITE_GAMES === type) {
value3 = (importDefault(22) /* metro dependency 22 */).uniqBy(a0.data.games.map(function(a0) {
return {applicationId: a0.game_id, comment: a0.comment, tags: a0.tags};
}), 'applicationId');
object2 = {};
object2.id = a0.id;
object2.type = type;
object2.games = value3;
value = Object.create(BaseGameWidget.prototype, {constructor: {value: BaseGameWidget}});
baseGameWidget = new BaseGameWidget();
return baseGameWidget instanceof Object ? baseGameWidget : value;
}
const PLAYED_GAMES = WidgetType.PLAYED_GAMES;
if (PLAYED_GAMES === type) {
value3 = (importDefault(22) /* metro dependency 22 */).uniqBy(a0.data.games.map(function(a0) {
return {applicationId: a0.game_id, comment: a0.comment, tags: a0.tags};
}), 'applicationId');
object2 = {};
object2.id = a0.id;
object2.type = type;
object2.games = value3;
value = Object.create(BaseGameWidget.prototype, {constructor: {value: BaseGameWidget}});
baseGameWidget = new BaseGameWidget();
return baseGameWidget instanceof Object ? baseGameWidget : value;
}
const WANT_TO_PLAY_GAMES = WidgetType.WANT_TO_PLAY_GAMES;
if (WANT_TO_PLAY_GAMES === type) {
value3 = (importDefault(22) /* metro dependency 22 */).uniqBy(a0.data.games.map(function(a0) {
return {applicationId: a0.game_id, comment: a0.comment, tags: a0.tags};
}), 'applicationId');
object2 = {};
object2.id = a0.id;
object2.type = type;
object2.games = value3;
value = Object.create(BaseGameWidget.prototype, {constructor: {value: BaseGameWidget}});
baseGameWidget = new BaseGameWidget();
return baseGameWidget instanceof Object ? baseGameWidget : value;
}
const APPLICATION = WidgetType.APPLICATION;
if (APPLICATION === type) {
ApplicationWidget = (require(5210) /* metro dependency 5210: UserProfileApplicationWidgetTypes */).ApplicationWidget;
object2 = {};
object2.id = a0.id;
object2.applicationId = a0.data.application_id;
value = Object.create(ApplicationWidget.prototype, {constructor: {value: ApplicationWidget}});
applicationWidget = new ApplicationWidget();
return applicationWidget instanceof Object ? applicationWidget : value;
}
}
function checkUserProfileCollectiblesExpiration(a0, a1) { // fn#45713, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:2043, offset: 0x011963a8, size: 274 bytes, params: 3, frame: 18
var r0;
var r5;
var value;
var items2;
var value4;
const env0_0 = a0;
const env0_1 = a1;
if (a1 != null) {
value = env0_19.get(a0);
if (value == null) {
r0 = undefined;
} else {
value = value.get(a1);
r0 = value;
}
r5 = r0;
} else {
r5 = env0_18.get(a0);
}
value = undefined;
if ((r5 == null ? value : r5.collectibles) != null) {
items2 = [];
r5.collectibles.forEach(_fun45714);
if (items2.length !== 0) {
r5.collectibles = r5.collectibles.filter(_fun45716);
items2.forEach(_fun45717);
if ('guildId' in r5) {
value4 = env0_19.get(a0);
if (value4 != null) {
value4.set(r5.guildId, r5);
}
} else {
env0_18.set(a0, r5);
}
env0_30.emitChange();
}
}
return value;
}
function handleLogout_45718() { // fn#45718, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:2996, offset: 0x0119673b, size: 111 bytes, params: 1, frame: 10
env0_16.clear();
env0_17.clear();
env0_18.clear();
env0_19.clear();
env0_21.clear();
env0_22.clear();
env0_23.clear();
}
function handleMutualFriendsFetchStart({userId}) { // fn#45719, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:3095, offset: 0x011967aa, size: 29 bytes, params: 2, frame: 11
env0_17.add(userId);
}
function handleMutualFriendsFetchFailure({userId}) { // fn#45720, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:3155, offset: 0x011967c7, size: 29 bytes, params: 2, frame: 11
env0_17.delete(userId);
}
function getMutualFriends(a0) { // fn#45721, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:3220, offset: 0x011967e4, size: 77 bytes, params: 2, frame: 12
let value = importDefault(22) /* metro dependency 22 */;
value = value(a0);
value = value.map(function(a0) {
var object = {key: a0.id};
var value2 = Object.create(UserRecord.prototype, {constructor: {value: UserRecord}});
var userRecord = new UserRecord(a0);
object.user = userRecord instanceof Object ? userRecord : value2;
object.status = PresenceStore.getStatus(a0.id);
return object;
});
value = value.sortBy(function(a0) {
var username = a0.user.username;
return username.toLowerCase();
});
return value.value();
}
function handleMutualFriendsFetchSuccess(a0) { // fn#45724, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:3385, offset: 0x01196895, size: 95 bytes, params: 2, frame: 17
let binding = env0_17;
let userId = a0.userId;
binding.delete(userId);
binding = env0_21;
let set = binding.set;
userId = a0.userId;
Reflect.apply(set, binding, [userId, getMutualFriends(a0.mutualFriends)]);
binding = env0_22;
set = binding.set;
userId = a0.userId;
Reflect.apply(set, binding, [userId, a0.mutualFriends.length]);
}
function handleProfileFetch({userProfile, fetchStartedAt, guildId}) { // fn#45725, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:3537, offset: 0x011968f4, size: 1720 bytes, params: 2, frame: 37
var r27;
var guild_id;
var r11;
var r8;
var set;
var value7;
var map;
var getMutualFriendsBinding;
var date;
var value19;
var defaultImport2;
var value21;
var env0_0;
let r7 = guildId ?? userProfile.guild_member_profile?.guild_id;
r7 = r7 ?? env0_15;
let binding = env0_16;
let get = binding.get;
let user = userProfile.user;
let id = user.id;
const value5 = Reflect.apply(get, binding, [id]);
if (value5 != null) {
value5.delete(r7);
}
binding = env0_17;
user = userProfile.user;
binding.delete(user.id);
if (userProfile.mutual_guilds != null) {
env0_0 = {};
userProfile.mutual_guilds.forEach(_fun45726);
binding = env0_23;
set = binding.set;
id = userProfile.user.id;
value7 = SortedGuildStore.getFlattenedGuildIds().filter(_fun45727);
Reflect.apply(set, binding, [id, value7.map(_fun45728)]);
}
let mutual_friends_count = userProfile.mutual_friends_count;
if (mutual_friends_count != null) {
mutual_friends_count = userProfile.mutual_friends_count;
binding = env0_22;
binding.set(userProfile.user.id, mutual_friends_count);
if (mutual_friends_count === 0) {
binding = env0_21;
binding.set(userProfile.user.id, env0_24);
}
}
let mutual_friends = userProfile.mutual_friends;
if (mutual_friends != null) {
binding = env0_21;
set = binding.set;
user = userProfile.user;
id = user.id;
getMutualFriendsBinding = getMutualFriends;
mutual_friends = userProfile.mutual_friends;
Reflect.apply(set, binding, [id, getMutualFriendsBinding(mutual_friends)]);
binding = env0_22;
set = binding.set;
user = userProfile.user;
id = user.id;
mutual_friends = userProfile.mutual_friends;
Reflect.apply(set, binding, [id, mutual_friends.length]);
}
if (userProfile.premium_since != null) {
date = new global.Date(userProfile.premium_since);
} else {
r11 = null;
}
if (userProfile.premium_guild_since != null) {
date = new global.Date(userProfile.premium_guild_since);
} else {
r8 = null;
}
const application = userProfile.application;
const r22 = userProfile.badges != null ? userProfile.badges.map(_fun45729) : [];
if (env0_29 != null && env0_29.userId === userProfile.user.id) {
if (!(global.Date.now() > env0_29.expiresAtMs)) {
mergePinnedBadges(r22, env0_29);
}
}
const Date = global.Date;
const value16 = Date.now();
binding = env0_18;
set = binding.set;
user = userProfile.user;
id = user.id;
let object2 = {};
const defaultImport = importDefault(dependencyMap[21]);
let user_profile = userProfile.user_profile;
copyDataProperties(object2, defaultImport(user_profile), r27);
user = userProfile.user;
object2['userId'] = user.id;
user_profile = userProfile.user_profile;
object2['banner'] = user_profile?.banner;
user_profile = userProfile.user_profile;
object2['accentColor'] = user_profile?.accent_color;
user_profile = userProfile.user_profile;
object2['themeColors'] = user_profile?.theme_colors;
user_profile = userProfile.user_profile;
object2['popoutAnimationParticleType'] = user_profile?.popout_animation_particle_type;
user_profile = userProfile.user_profile;
const bio = user_profile?.bio;
const value17 = '';
object2['bio'] = bio ?? value17;
user_profile = userProfile.user_profile;
let r23 = user_profile?.pronouns ?? value17;
object2['pronouns'] = r23;
object2['connectedAccounts'] = userProfile.connected_accounts.filter(_fun45730) ?? [];
object2['applicationRoleConnections'] = userProfile.application_role_connections ?? [];
object2['premiumSince'] = r11;
object2['premiumType'] = userProfile.premium_type;
object2['premiumGuildSince'] = r8;
object2['fetchStartedAt'] = fetchStartedAt;
object2['fetchEndedAt'] = value16;
object2['legacyUsername'] = userProfile.legacy_username;
object2['application'] = application != null ? {id: application.id, primarySkuId: application.primary_sku_id,
customInstallUrl: application.custom_install_url, installParams: application.install_params,
integrationTypesConfig: application.integration_types_config, flags: application.flags,
popularApplicationCommandIds: application.popular_application_command_ids,
storefront_available: application.storefront_available, name: application.name} : null;
object2['badges'] = r22;
const widgets = userProfile.widgets;
if (widgets == null) {
r23 = undefined;
} else {
value19 = widgets.map(createUserWidgetFromServer);
r23 = value19.filter(require(dependencyMap[23]).isNotNullish);
r27 = dependencyMap;
}
object2['widgets'] = r23;
object2['wishlistSettings'] = userProfile.wishlist_settings;
object2['private'] = userProfile.private;
Reflect.apply(set, binding, [id, object2]);
let checkUserProfileCollectiblesExpirationBinding = checkUserProfileCollectiblesExpiration;
user = userProfile.user;
checkUserProfileCollectiblesExpirationBinding(user.id);
let guild_member_profile = userProfile.guild_member_profile;
if (guild_member_profile != null) {
object2 = {};
defaultImport2 = importDefault(dependencyMap[21]);
guild_member_profile = userProfile.guild_member_profile;
copyDataProperties(object2, defaultImport2(guild_member_profile), r27);
user = userProfile.user;
id = user.id;
object2['userId'] = id;
guild_member_profile = userProfile.guild_member_profile;
guild_id = guild_member_profile.guild_id;
object2['guildId'] = guild_id;
guild_member_profile = userProfile.guild_member_profile;
object2['banner'] = guild_member_profile.banner;
guild_member_profile = userProfile.guild_member_profile;
object2['accentColor'] = guild_member_profile.accent_color;
guild_member_profile = userProfile.guild_member_profile;
object2['themeColors'] = guild_member_profile?.theme_colors;
guild_member_profile = userProfile.guild_member_profile;
object2['popoutAnimationParticleType'] = guild_member_profile?.popout_animation_particle_type;
guild_member_profile = userProfile.guild_member_profile;
object2['bio'] = guild_member_profile.bio;
guild_member_profile = userProfile.guild_member_profile;
object2['pronouns'] = guild_member_profile.pronouns;
object2['badges'] = userProfile.guild_badges;
object2['fetchStartedAt'] = fetchStartedAt;
object2['fetchEndedAt'] = value16;
binding = env0_19;
get = binding.get;
user = userProfile.user;
id = user.id;
value21 = Reflect.apply(get, binding, [id]);
if (value21 != null) {
value21.set(userProfile.guild_member_profile.guild_id, object2);
} else {
map = new global.Map();
map.set(userProfile.guild_member_profile.guild_id, object2);
env0_19.set(userProfile.user.id, map);
}
checkUserProfileCollectiblesExpirationBinding = checkUserProfileCollectiblesExpiration;
user = userProfile.user;
id = user.id;
guild_member_profile = userProfile.guild_member_profile;
guild_id = guild_member_profile.guild_id;
checkUserProfileCollectiblesExpirationBinding(id, guild_id);
}
}
function mergePinnedBadges(a0, a1) { // fn#45731, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:6966, offset: 0x011971d6, size: 142 bytes, params: 3, frame: 17
var r4;
var Set;
var value;
var set;
var push;
var items2;
if (a0 != null) {
Set = global.Set;
value = a0.map(function(a0) {
return a0.id;
});
set = new Set();
set = undefined;
r4 = a1 == null ? set : a1.badges.filter(_fun45733);
if (r4.length > 0) {
push = a0.push;
items2 = [];
arraySpread(items2, r4, 0, Set);
apply(push, items2, a0, Set);
}
return a0;
}
}
function handleProfileFetchStart({userId, guildId, withMutualFriends}) { // fn#45734, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:7129, offset: 0x01197264, size: 139 bytes, params: 2, frame: 17
var set;
const r5 = guildId ?? env0_15;
const value2 = env0_16.get(userId);
if (value2 != null) {
value2.add(r5);
} else {
set = new global.Set();
set.add(r5);
env0_16.set(userId, set);
}
if (withMutualFriends) {
env0_17.add(userId);
}
}
function handleProfileFetchFailure({userId, guildId, apiError, fetchStartedAt}) { // fn#45735, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:7304, offset: 0x011972ef, size: 343 bytes, params: 2, frame: 19
var r3;
let binding = env0_16;
const value2 = binding.get(userId);
if (value2 != null) {
value2.delete(guildId ?? env0_15);
}
env0_17.delete(userId);
const r8 = env0_18.get(userId) ?? ({'connectedAccounts': null, 'applicationRoleConnections': null,
'premiumSince': null, 'premiumGuildSince': null, 'application': null, 'legacyUsername': null, 'userId': null,
'banner': null, 'accentColor': null, 'bio': '', 'pronouns': '', 'premiumType': null, 'fetchStartedAt': 0,
'fetchEndedAt': 0, connectedAccounts: [], applicationRoleConnections: [], userId: userId,
fetchError: undefined});
const Date = global.Date;
const value4 = Date.now();
r8.fetchStartedAt = fetchStartedAt;
r8.fetchEndedAt = value4;
r8.fetchError = apiError;
env0_18.set(userId, r8);
if (guildId != null) {
r3 = env0_19.get(userId)?.get(guildId);
if (r3 != null) {
r3.fetchStartedAt = fetchStartedAt;
r3.fetchEndedAt = value4;
r3.fetchError = apiError;
}
}
if (apiError?.status === 404) {
binding = env0_22;
binding.set(userId, 0);
binding = env0_21;
binding.set(userId, env0_24);
binding = env0_23;
binding.set(userId, env0_25);
}
}
function handleProfileUpdateSuccess(a0) { // fn#45737, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:8034, offset: 0x01197453, size: 459 bytes, params: 2, frame: 26
var userId;
var accent_color;
var banner;
var bio;
var pronouns;
var popout_animation_particle_type;
var theme_colors;
var collectibles;
var binding;
var value2;
var set;
var object2;
var value3;
var value4;
let guild_id = a0.guild_id;
if (guild_id != null) {
userId = a0.userId;
guild_id = a0.guild_id;
accent_color = a0.accent_color;
banner = a0.banner;
bio = a0.bio;
pronouns = a0.pronouns;
popout_animation_particle_type = a0.popout_animation_particle_type;
theme_colors = a0.theme_colors;
collectibles = a0.collectibles;
value3 = env0_19.get(userId);
if (guild_id != null) {
if (value3 != null) {
value4 = value3.get(guild_id);
if (value4 != null) {
set = value3.set;
object2 = {};
copyDataProperties(object2, value4, undefined);
copyDataProperties(object2,
(importDefault(5212) /* metro dependency 5212: parseUserProfileCollectibles */)({collectibles: collectibles}),
undefined);
object2['accentColor'] = accent_color;
object2['banner'] = banner;
object2['bio'] = bio;
object2['pronouns'] = pronouns;
object2['popoutAnimationParticleType'] = popout_animation_particle_type;
object2['themeColors'] = theme_colors;
Reflect.apply(set, value3, [guild_id, object2]);
checkUserProfileCollectiblesExpiration(userId, guild_id);
}
}
}
} else {
userId = a0.userId;
accent_color = a0.accent_color;
banner = a0.banner;
bio = a0.bio;
pronouns = a0.pronouns;
popout_animation_particle_type = a0.popout_animation_particle_type;
theme_colors = a0.theme_colors;
collectibles = a0.collectibles;
binding = env0_18;
value2 = binding.get(userId);
if (value2 != null) {
binding = env0_18;
set = binding.set;
object2 = {};
copyDataProperties(object2, value2, collectibles);
copyDataProperties(object2,
(importDefault(5212) /* metro dependency 5212: parseUserProfileCollectibles */)({collectibles: collectibles}),
collectibles);
object2['accentColor'] = accent_color;
object2['banner'] = banner;
object2['bio'] = bio;
object2['pronouns'] = pronouns;
object2['popoutAnimationParticleType'] = popout_animation_particle_type;
object2['themeColors'] = theme_colors;
Reflect.apply(set, binding, [userId, object2]);
checkUserProfileCollectiblesExpiration(userId);
}
}
}
function handleWidgetsUpdateSuccess({userId, widgets}) { // fn#45739, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:8916, offset: 0x0119762b, size: 131 bytes, params: 2, frame: 18
let binding = env0_18;
const value2 = binding.get(userId);
if (value2 == null) {
return false;
}
binding = env0_18;
const set = binding.set;
const object2 = {};
copyDataProperties(object2, value2, undefined);
const value3 = widgets.map(createUserWidgetFromServer);
object2['widgets'] = value3.filter((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish);
Reflect.apply(set, binding, [userId, object2]);
}
function handlePinBadgesToProfile({badges, ttlInSeconds, userId}) { // fn#45740, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:9098, offset: 0x011976ae, size: 164 bytes, params: 2, frame: 16
var r5;
var mergePinnedBadgesBinding;
var set;
let object2 = {userId: userId, badges: badges};
const Date = global.Date;
object2.expiresAtMs = Date.now() + 1000 * ttlInSeconds;
env0_29 = object2;
let binding = env0_18;
const value2 = binding.get(userId);
if (value2 != null) {
r5 = value2.badges ?? [];
mergePinnedBadgesBinding = mergePinnedBadges;
mergePinnedBadgesBinding(r5, env0_29);
binding = env0_18;
set = binding.set;
object2 = {};
copyDataProperties(object2, value2, mergePinnedBadgesBinding);
object2['badges'] = r5;
Reflect.apply(set, binding, [userId, object2]);
}
}
function handleUserUpdate_45741({user}) { // fn#45741, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:9327, offset: 0x01197752, size: 83 bytes, params: 2, frame: 15
const id = user.id;
let r0 = env0_16.get(id)?.size ?? 0;
r0 = !(r0 > 0) && resetProfileFetch(id);
return r0;
}
function handleGuildStatusChange() { // fn#45742, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:9458, offset: 0x011977a5, size: 52 bytes, params: 1, frame: 14
const value = env0_18.keys();
const items2 = [];
arraySpread(items2, value, 0, items2);
return items2.reduce(function(a0, a1) {
return resetProfileFetch(a1) || a0;
}, false);
}
function handleLocaleStoreChange() { // fn#45746, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:9722, offset: 0x01197830, size: 63 bytes, params: 1, frame: 10
env0_16.clear();
env0_17.clear();
env0_18.clear();
env0_19.clear();
}
function resetProfileFetch(a0) { // fn#45747, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:9797, offset: 0x0119786f, size: 151 bytes, params: 2, frame: 15
var r2;
var _createForOfIteratorHelperLoose_45708Binding;
var values;
var value4;
var done;
var value5;
var value6;
if (a0 == null) {
return false;
}
let value = environment;
const value2 = env0_18.get(a0);
if (value2 == null) {
return false;
}
value2.fetchStartedAt = 0;
value2.fetchEndedAt = 0;
value2.fetchError = undefined;
const value3 = env0_19.get(a0);
reducibleJoin5: while (true) {
if (value3 == null) {
break reducibleJoin5;
}
_createForOfIteratorHelperLoose_45708Binding = _createForOfIteratorHelperLoose_45708;
values = value3.values;
value = _createForOfIteratorHelperLoose_45708Binding(Reflect.apply(values, value3, []));
value4 = value();
done = value4.done;
if (done) {
break reducibleJoin5;
}
r2 = value4;
reducibleLoop4: while (true) {
value5 = r2.value;
value5.fetchStartedAt = 0;
value5.fetchEndedAt = 0;
value5.fetchError = undefined;
value6 = value();
done = value6.done;
if (done) {
break reducibleJoin5;
}
r2 = value6;
continue reducibleLoop4;
}
}
}
function handleAppWidgetConfigsFetchSuccess({applicationConfigs}) { // fn#45748, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:10107, offset: 0x01197906, size: 116 bytes, params: 2, frame: 17
var r2;
var value4;
var set;
var applicationId;
var value5;
env0_26 = applicationConfigs.map(_fun45749);
let binding = env0_27;
binding.clear();
value = _createForOfIteratorHelperLoose_45708(env0_26);
const value3 = value();
let done = value3.done;
if (!done) {
for (r2 = value3; true; r2 = value5) {
value4 = r2.value;
binding = env0_27;
set = binding.set;
applicationId = value4.applicationId;
Reflect.apply(set, binding, [applicationId, value4]);
value5 = value();
done = value5.done;
if (done) {
break;
}
}
}
}
function _fun45750(a0) { // fn#45750, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:10348, offset: 0x011979b2, size: 419 bytes, params: 2, frame: 16
const closure = UserProfileStore;
env0_7(closure, a0);
return env0_4(closure, [{key: 'initialize', value: function() {
this.waitFor(SortedGuildStore);
this.syncWith([LocaleStore], handleLocaleStoreChange);
}}, {key: 'isFetchingProfile', value: value_45756}, {key: 'isFetchingFriends', value: value_45757},
{key: 'isSubmitting', get: get_45758}, {key: 'getUserProfile', value: value_45759},
{key: 'getGuildMemberProfile', value: value_45760}, {key: 'getMutualFriends', value: value_45761},
{key: 'getMutualFriendsCount', value: value_45762}, {key: 'getMutualGuilds', value: value_45763},
{key: 'getWidgets', value: value_45764}, {key: 'getWishlistIds', value: value_45765},
{key: 'getFirstWishlistId', value: function(a0) {
var value = null;
if (value == a0) {
return value;
}
var value2 = this.getWishlistIds(a0);
return value2.length > 0 ? value2[0] : value;
}}, {key: 'getWishlistSettings', value: value_45767}, {key: 'takeSnapshot', value: value_45768},
{key: 'applicationWidgetConfigs', get: get_45769}, {key: 'getApplicationWidgetConfig', value: value_45770}]);
}
function _fun45714(a0) { // fn#45714, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:2234, offset: 0x011964ba, size: 428 bytes, params: 2, frame: 20
var environment;
var r3;
var value;
var Date;
var value2;
var binding;
var property;
var skuId;
var Timeout;
var value4;
var timeout;
var start;
if (a0.expiresAt != null) {
value = a0.expiresAt.getTime();
Date = global.Date;
value -= Date.now();
if (value <= 0) {
env0_3.push(a0);
} else {
value2 = environment.__proto__;
binding = env1_20;
if (binding[env0_0] == null) {
env1_20[env0_0] = {[env1_15]: {}};
}
binding = env1_20;
property = binding[env0_0];
r3 = require ?? env1_15;
if (property[r3] == null) {
env1_20[env0_0][require ?? env1_15] = {};
}
binding = env1_20;
property = binding[env0_0];
r3 = require ?? env1_15;
property = property[r3];
skuId = a0.skuId;
if (property[skuId] == null) {
property = env1_20[env0_0];
property = property[require ?? env1_15];
skuId = a0.skuId;
Timeout = (require(4041) /* metro dependency 4041: Timers */).Timeout;
value4 = Object.create(Timeout.prototype, {constructor: {value: Timeout}});
timeout = new Timeout();
property[skuId] = timeout instanceof Object ? timeout : value4;
}
binding = env1_20;
property = binding[env0_0];
r3 = require ?? env1_15;
property = property[r3];
skuId = a0.skuId;
property = property[skuId];
start = property.start;
value = global.Math.min(MAX_TIMEOUT_MS, value);
Reflect.apply(start, property, [value, _fun45715]);
}
}
}
function _fun45717(a0) { // fn#45717, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:2680, offset: 0x01196682, size: 185 bytes, params: 2, frame: 17
var r2;
var r3;
const type = a0.type;
let value = environment.__proto__;
const CollectiblesItemType = (require(1904) /* metro dependency 1904: CollectiblesItemType */).CollectiblesItemType;
const PROFILE_EFFECT = CollectiblesItemType.PROFILE_EFFECT;
if (type === PROFILE_EFFECT) {
env0_2.profileEffect = undefined;
} else if (a0.type === CollectiblesItemType.PROFILE_FRAME) {
env0_2.profileFrame = undefined;
}
let property = env1_20[env0_0];
const value5 = property == null;
if (value5) {
r2 = property;
r3 = value5;
} else {
property = property[require ?? env1_15];
value = property == null;
r2 = property;
r3 = value;
}
if (!r3) {
delete r2[a0.skuId];
}
}
function _fun45726({id, nick}) { // fn#45726, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:3838, offset: 0x01196fac, size: 64 bytes, params: 2, frame: 13
let value = environment.__proto__;
value = GuildStore.getGuild(id);
if (value != null) {
env0_0[id] = {guild: value, nick: nick};
}
}
function _fun45728(a0) { // fn#45728, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:3982, offset: 0x01197002, size: 46 bytes, params: 2, frame: 4
return {guild: env0_0[a0].guild, nick: env0_0[a0].nick};
}
function _fun45729(a0) { // fn#45729, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:4423, offset: 0x01197030, size: 376 bytes, params: 2, frame: 23
var r2;
var object2;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
let value = a0;
const tieredTenureBadgeUtilsModule = require(5211) /* metro dependency 5211: TieredTenureBadgeUtils */;
const getTieredTenureBadgeData = tieredTenureBadgeUtilsModule.getTieredTenureBadgeData;
let id = value.id;
const value3 = Reflect.apply(getTieredTenureBadgeData, tieredTenureBadgeUtilsModule, [id]);
id = value.id;
if (id !== 'premium') {
if (value3 == null) {
id = value.id;
if (id.startsWith('guild_booster_lvl')) {
if (env0_2 == null) {
r2 = value;
} else {
object2 = {};
copyDataProperties(object2, value, undefined);
value = intl.formatToPlainString(t.IWkAq7, {date: env0_2});
object2['description'] = value;
r2 = object2;
}
} else {
r2 = value;
}
return r2;
}
}
if (env0_1 != null) {
r2 = value3 == null ? intl.formatToPlainString(t['8zbGNR'], {date: env0_1}) : intl.formatToPlainString(t.Hu4jfi,
{date: env0_1});
object2 = {};
copyDataProperties(object2, value, undefined);
object2['description'] = r2;
return object2;
}
id = value.id;
if (id.startsWith('guild_booster_lvl')) {
if (env0_2 == null) {
r2 = value;
} else {
object2 = {};
copyDataProperties(object2, value, undefined);
value = intl.formatToPlainString(t.IWkAq7, {date: env0_2});
object2['description'] = value;
r2 = object2;
}
} else {
r2 = value;
}
return r2;
}
function _fun45730({type}) { // fn#45730, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:5446, offset: 0x011971a8, size: 46 bytes, params: 2, frame: 11
const value = environment.__proto__;
return (importDefault(4915) /* metro dependency 4915: Platforms */).isSupported(type);
}
function _fun45749(a0) { // fn#45749, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:10182, offset: 0x0119797a, size: 56 bytes, params: 2, frame: 11
let value = environment.__proto__;
const ApplicationWidgetConfig = (require(5213) /* metro dependency 5213: ApplicationWidgetConfig */).ApplicationWidgetConfig;
value = Object.create(ApplicationWidgetConfig.prototype, {constructor: {value: ApplicationWidgetConfig}});
const applicationWidgetConfig = new ApplicationWidgetConfig(a0);
return applicationWidgetConfig instanceof Object ? applicationWidgetConfig : value;
}
function UserProfileStore() { // fn#45751, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:10360, offset: 0x01197b55, size: 342 bytes, params: 1, frame: 20
var environment;
let value = environment.__proto__;
env1_3(this, UserProfileStore);
const handleUserUpdate_45741Binding = handleUserUpdate_45741;
const handleGuildStatusChangeBinding = handleGuildStatusChange;
const handleGuildMemberStatusChangeBinding = handleGuildMemberStatusChange;
const handleRelationshipStatusChangeBinding = handleRelationshipStatusChange;
const items2 = [{CACHE_LOADED_LAZY: CACHE_LOADED_LAZY_45752, USER_PROFILE_FETCH_START: handleProfileFetchStart,
USER_PROFILE_FETCH_FAILURE: handleProfileFetchFailure, USER_PROFILE_FETCH_SUCCESS: handleProfileFetch,
USER_PROFILE_UPDATE_START: handleProfileUpdateStart, USER_PROFILE_UPDATE_SUCCESS: handleProfileUpdateSuccess,
USER_PROFILE_UPDATE_FAILURE: handleProfileUpdateFailure,
WIDGET_PENDING_SAVE_SUCCESS: handleWidgetsUpdateSuccess,
USER_PROFILE_PIN_BADGES_ON_CLIENT: handlePinBadgesToProfile,
MUTUAL_FRIENDS_FETCH_START: handleMutualFriendsFetchStart,
MUTUAL_FRIENDS_FETCH_SUCCESS: handleMutualFriendsFetchSuccess,
MUTUAL_FRIENDS_FETCH_FAILURE: handleMutualFriendsFetchFailure, USER_UPDATE: handleUserUpdate_45741Binding,
GUILD_MEMBER_UPDATE: handleUserUpdate_45741Binding, GUILD_JOIN: handleGuildStatusChangeBinding,
GUILD_DELETE: handleGuildStatusChangeBinding, INVITE_ACCEPT_SUCCESS: handleGuildStatusChangeBinding,
GUILD_MEMBER_ADD: handleGuildMemberStatusChangeBinding,
GUILD_MEMBER_REMOVE: handleGuildMemberStatusChangeBinding,
RELATIONSHIP_ADD: handleRelationshipStatusChangeBinding,
RELATIONSHIP_REMOVE: handleRelationshipStatusChangeBinding,
RELATIONSHIP_UPDATE: handleRelationshipStatusChangeBinding,
USER_PROFILE_APPLICATION_WIDGET_CONFIGS_FETCH_SUCCESS: handleAppWidgetConfigsFetchSuccess,
LOGOUT: handleLogout_45718}];
const value3 = env1_6(UserProfileStore);
value = env1_5(this, _isNativeReflectConstruct_45705() ? global.Reflect.construct(value3, items2,
env1_6(this).constructor) : value3.apply(this, items2));
value.loadCache = loadCache;
return value;
}
function value_45756(a0, a1) { // fn#45756, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:12114, offset: 0x01197d5b, size: 52 bytes, params: 3, frame: 14
const value = a1;
const value3 = env1_16.get(a0);
return value3 != null && value3.has(value ?? env1_15);
}
function value_45760(a0, a1) { // fn#45760, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:12380, offset: 0x01197d8f, size: 70 bytes, params: 3, frame: 14
var r2;
var r0;
var value2;
var value3;
const value = null;
if (value == a1) {
r0 = value;
} else {
value2 = environment.__proto__;
value3 = env1_19.get(a0);
r2 = value == value3 ? undefined : value3.get(a1);
r0 = value != r2 ? r2 : value;
}
return r0;
}
function value_45763(a0) { // fn#45763, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:12630, offset: 0x01197e01, size: 22 bytes, params: 2, frame: 11
return env1_23.get(a0);
}
function value_45764(a0) { // fn#45764, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:12684, offset: 0x01197e17, size: 39 bytes, params: 2, frame: 11
const value = environment.__proto__;
return env1_18.get(a0)?.widgets;
}
function value_45765(a0) { // fn#45765, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:12775, offset: 0x01197e3e, size: 73 bytes, params: 2, frame: 12
let value = environment.__proto__;
value = env1_18.get(a0);
return value?.wishlistSettings != null ? global.Object.keys(value.wishlistSettings) : [];
}
function value_45767(a0, a1) { // fn#45767, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:13047, offset: 0x01197eb8, size: 67 bytes, params: 3, frame: 13
let value = environment.__proto__;
value = env1_18.get(a0);
const value2 = null;
const r1 = value2 == value || value2 == value.wishlistSettings ? undefined : value.wishlistSettings[a1];
return value2 != r1 ? r1 : value2;
}
function value_45768() { // fn#45768, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:13182, offset: 0x01197efb, size: 115 bytes, params: 1, frame: 13
let value = environment.__proto__;
const id = AuthenticationStore.getId();
value = env1_18.get(id);
return value != null ? {version: UserProfileStore.LATEST_SNAPSHOT_VERSION, data: [{userId: id,
profile: value}]} : {version: UserProfileStore.LATEST_SNAPSHOT_VERSION, data: []};
}
function value_45770(a0) { // fn#45770, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:13473, offset: 0x01197f6e, size: 22 bytes, params: 2, frame: 11
return env1_27.get(a0);
}
function _fun45715() { // fn#45715, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:2532, offset: 0x01196666, size: 28 bytes, params: 1, frame: 13
checkUserProfileCollectiblesExpiration(env1_0, require);
}
function UserProfileStoreLoadCache() { // fn#45753, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:11777, owner: UserProfileStore.loadCache, offset: 0x01197cab, size: 58 bytes, params: 1, frame: 11
var environment;
const binding = env0_0;
const readSnapshot = binding.readSnapshot;
let value = environment.__proto__;
const LATEST_SNAPSHOT_VERSION = UserProfileStore.LATEST_SNAPSHOT_VERSION;
value = Reflect.apply(readSnapshot, binding, [LATEST_SNAPSHOT_VERSION]);
if (value != null) {
value.forEach(_fun45754);
}
}
function _fun45754({userId, profile}) { // fn#45754, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5367:11865, offset: 0x01197ce5, size: 65 bytes, params: 2, frame: 13
var value;
if (userId != null) {
if (profile != null) {
value = environment.__proto__.__proto__.__proto__;
env3_18.set(userId, profile);
} else {
value = environment.__proto__.__proto__.__proto__;
env3_18.delete(userId);
}
}
}