692 lines
22 KiB
TypeScript
692 lines
22 KiB
TypeScript
// Metro module 5896 (f5897).
|
|
import LocaleStore from "../user_settings/LocaleStore";
|
|
import UserRecord from "../../records/UserRecord";
|
|
import AuthenticationStore from "../../stores/AuthenticationStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import MobileCacheSnapshotStore from "../../stores/MobileCacheSnapshotStore";
|
|
import PresenceStore from "../../stores/PresenceStore";
|
|
import SortedGuildStore from "../../stores/SortedGuildStore";
|
|
import { MAX_TIMEOUT_MS } from "../../Constants";
|
|
import { WidgetType } from "../../_bundle/Module5897";
|
|
import Module12 from "../../_bundle/Module12";
|
|
import { BaseGameWidget } from "./UserProfileGameWidgetTypes";
|
|
import { ApplicationWidget } from "./UserProfileApplicationWidgetTypes";
|
|
import { UserProfilePersonalWidget } from "./UserProfilePersonalWidget";
|
|
import { Timeout } from "../../_bundle/Timeout";
|
|
import { CollectiblesItemType } from "../../_bundle/Module1901";
|
|
import { parseServerUserCollectibles } from "../collectibles/utils/mappers";
|
|
import { getTieredTenureBadgeData } from "./TieredTenureBadgeUtils";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import parseUserProfileCollectibles from "./utils/parseUserProfileCollectibles";
|
|
import Platforms from "../../lib/Platforms";
|
|
import { isNotNullish } from "../../utils/GlobalUtils";
|
|
function $mk77310() {
|
|
return (a0) => a0.user.username.toLowerCase();
|
|
}
|
|
function $mk77316() {
|
|
return (a0) => a0.id;
|
|
}
|
|
function $mk77317($env) {
|
|
return (a0) => !$env[0].has(a0.id);
|
|
}
|
|
let c3691_10, c3691_11, c3691_12, c3691_13, c3691_14, c3691_15, c3691_16, c3691_17, c3691_18, c3691_19, c3691_20, c3691_22, c3691_23, checkUserProfileCollectiblesExpiration, handleLogout, handleMutualFriendsFetchStart, handleMutualFriendsFetchFailure, handleMutualFriendsFetchSuccess, handleProfileFetch, handleProfileFetchStart, handleProfileFetchFailure, handleProfileUpdateStart, handleProfileUpdateSuccess, handleProfileUpdateFailure, handleWidgetsUpdateSuccess, handlePinBadgesToProfile, handleUserUpdate, handleGuildStatusChange, handleGuildMemberStatusChange, handleRelationshipStatusChange, handleLocaleStoreChange, resetProfileFetch, c3691_43, $mk77309 = function() {
|
|
return (a0) => ({
|
|
key: a0.id,
|
|
user: new UserRecord({
|
|
...a0,
|
|
collectibles: parseServerUserCollectibles(a0.collectibles)
|
|
}),
|
|
status: PresenceStore.getStatus(a0.id)
|
|
});
|
|
};
|
|
const createUserWidgetFromServer = function createUserWidgetFromServer(a0) {
|
|
let userProfilePersonalWidget;
|
|
const type = a0.data.type;
|
|
if (WidgetType.CURRENT_GAMES !== type && WidgetType.FAVORITE_GAMES !== type && WidgetType.PLAYED_GAMES !== type && WidgetType.WANT_TO_PLAY_GAMES !== type) {
|
|
if (WidgetType.APPLICATION === type) {
|
|
return new ApplicationWidget({
|
|
id: a0.id,
|
|
applicationId: a0.data.application_id
|
|
});
|
|
}
|
|
if (WidgetType.PERSONAL === type) {
|
|
if (a0.data.title == null) {
|
|
return void 0;
|
|
}
|
|
try {
|
|
const r43 = JSON.parse(a0.data.title);
|
|
userProfilePersonalWidget = new UserProfilePersonalWidget({
|
|
id: a0.id,
|
|
header: r43.header,
|
|
top: r43.top,
|
|
bottom: r43.bottom
|
|
});
|
|
} catch ($e) {
|
|
return void 0;
|
|
}
|
|
return userProfilePersonalWidget;
|
|
}
|
|
return void 0;
|
|
}
|
|
return new BaseGameWidget({
|
|
id: a0.id,
|
|
type,
|
|
games: Module12.uniqBy(a0.data.games.map((game) => ({
|
|
applicationId: game.game_id,
|
|
comment: game.comment,
|
|
tags: game.tags
|
|
})), "applicationId")
|
|
});
|
|
};
|
|
checkUserProfileCollectiblesExpiration = function checkUserProfileCollectiblesExpiration(a0, guild_id) {
|
|
let r12;
|
|
let c15241_3;
|
|
if (guild_id != null) {
|
|
const r10 = c3691_14.get(a0);
|
|
r12 = r10 == null ? void 0 : r10.get(guild_id);
|
|
} else {
|
|
r12 = c3691_13.get(a0);
|
|
}
|
|
let c15241_2 = r12;
|
|
if (r12?.collectibles != null) {
|
|
const r18 = [];
|
|
c15241_3 = r18;
|
|
r12.collectibles.forEach((collectible) => {
|
|
if (collectible.expiresAt != null) {
|
|
const r10 = collectible.expiresAt.getTime() - Date.now();
|
|
if (r10 <= 0) {
|
|
c15241_3.push(collectible);
|
|
} else {
|
|
if (c3691_15[a0] == null) {
|
|
const r25 = {};
|
|
r25[c3691_10] = {};
|
|
c3691_15[a0] = r25;
|
|
}
|
|
const r26 = c3691_15[a0];
|
|
let r27 = guild_id;
|
|
if (r26[r27 == null ? c3691_10 : r27] == null) {
|
|
c3691_15[a0][r27 == null ? c3691_10 : r27] = {};
|
|
}
|
|
if (c3691_15[a0][r27 == null ? c3691_10 : r27][collectible.skuId] == null) {
|
|
c3691_15[a0][r27 == null ? c3691_10 : r27][collectible.skuId] = new Timeout();
|
|
}
|
|
const r48 = c3691_15[a0];
|
|
if (r27 == null) {
|
|
r27 = c3691_10;
|
|
}
|
|
r48[r27][collectible.skuId].start(Math.min(MAX_TIMEOUT_MS, r10), () => {
|
|
checkUserProfileCollectiblesExpiration(a0, guild_id);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
if (r18.length !== 0) {
|
|
r12.collectibles = r12.collectibles.filter((collectible) => !c15241_3.includes(collectible));
|
|
r18.forEach((item) => {
|
|
if (item.type === CollectiblesItemType.PROFILE_EFFECT) {
|
|
c15241_2.profileEffect = void 0;
|
|
} else if (item.type === CollectiblesItemType.PROFILE_FRAME) {
|
|
c15241_2.profileFrame = void 0;
|
|
}
|
|
const r21 = c3691_15[a0];
|
|
if (r21 != null) {
|
|
let r22 = guild_id;
|
|
if (r22 == null) {
|
|
r22 = c3691_10;
|
|
}
|
|
const r23 = r21[r22];
|
|
if (r23 != null) {
|
|
delete r23[item.skuId];
|
|
}
|
|
}
|
|
});
|
|
if ("guildId" in r12) {
|
|
const r38 = c3691_14.get(a0);
|
|
if (r38 != null) {
|
|
r38.set(r12.guildId, r12);
|
|
}
|
|
} else {
|
|
c3691_13.set(a0, r12);
|
|
}
|
|
c3691_43.emitChange();
|
|
}
|
|
}
|
|
};
|
|
handleLogout = function handleLogout() {
|
|
c3691_11.clear();
|
|
c3691_12.clear();
|
|
c3691_13.clear();
|
|
c3691_14.clear();
|
|
c3691_16.clear();
|
|
c3691_17.clear();
|
|
c3691_18.clear();
|
|
c3691_22 = false;
|
|
};
|
|
handleMutualFriendsFetchStart = function handleMutualFriendsFetchStart(a0) {
|
|
c3691_12.add(a0.userId);
|
|
};
|
|
handleMutualFriendsFetchFailure = function handleMutualFriendsFetchFailure(a0) {
|
|
c3691_12.delete(a0.userId);
|
|
};
|
|
handleMutualFriendsFetchSuccess = function handleMutualFriendsFetchSuccess(a0) {
|
|
c3691_12.delete(a0.userId);
|
|
c3691_16.set(a0.userId, Module12(a0.mutualFriends).map($mk77309()).sortBy($mk77310()).value());
|
|
c3691_17.set(a0.userId, a0.mutualFriends.length);
|
|
};
|
|
handleProfileFetch = function handleProfileFetch(a0) {
|
|
let c15242_0, date, date2;
|
|
const { userProfile, fetchStartedAt } = a0;
|
|
let guildId = a0.guildId;
|
|
c15242_0 = void 0;
|
|
date = void 0;
|
|
date2 = void 0;
|
|
if (guildId == null) {
|
|
guildId = userProfile.guild_member_profile?.guild_id;
|
|
}
|
|
if (guildId == null) {
|
|
guildId = c3691_10;
|
|
}
|
|
const r31 = c3691_11.get(userProfile.user.id);
|
|
if (r31 != null) {
|
|
r31.delete(guildId);
|
|
}
|
|
c3691_12.delete(userProfile.user.id);
|
|
if (userProfile.mutual_guilds != null) {
|
|
c15242_0 = {};
|
|
userProfile.mutual_guilds.forEach(({ id, nick }) => {
|
|
const guild = GuildStore.getGuild(id);
|
|
if (guild != null) {
|
|
c15242_0[id] = {
|
|
guild,
|
|
nick
|
|
};
|
|
}
|
|
});
|
|
c3691_18.set(userProfile.user.id, SortedGuildStore.getFlattenedGuildIds().filter((item) => c15242_0[item] != null).map((item) => ({
|
|
guild: c15242_0[item].guild,
|
|
nick: c15242_0[item].nick
|
|
})));
|
|
}
|
|
if (userProfile.mutual_friends_count != null) {
|
|
const mutual_friends_count = userProfile.mutual_friends_count;
|
|
c3691_17.set(userProfile.user.id, mutual_friends_count);
|
|
if (mutual_friends_count === 0) {
|
|
c3691_16.set(userProfile.user.id, c3691_19);
|
|
}
|
|
}
|
|
if (userProfile.mutual_friends != null) {
|
|
c3691_16.set(userProfile.user.id, Module12(userProfile.mutual_friends).map($mk77309()).sortBy($mk77310()).value());
|
|
c3691_17.set(userProfile.user.id, userProfile.mutual_friends.length);
|
|
}
|
|
date = userProfile.premium_since != null ? new Date(userProfile.premium_since) : null;
|
|
date2 = userProfile.premium_guild_since != null ? new Date(userProfile.premium_guild_since) : null;
|
|
const application = userProfile.application;
|
|
const badges = userProfile.badges != null ? userProfile.badges.map((badge) => {
|
|
const tieredTenureBadgeData = getTieredTenureBadgeData(badge.id);
|
|
if (!(badge.id !== "premium" && tieredTenureBadgeData == null) && date != null) {
|
|
let description = intl.formatToPlainString(t["8zbGNR"], {
|
|
date
|
|
});
|
|
if (tieredTenureBadgeData != null) {
|
|
description = intl.formatToPlainString(t.Hu4jfi, {
|
|
date
|
|
});
|
|
}
|
|
return {
|
|
...badge,
|
|
description
|
|
};
|
|
}
|
|
return badge.id.startsWith("guild_booster_lvl") ? date2 != null ? {
|
|
...badge,
|
|
description: intl.formatToPlainString(t.IWkAq7, {
|
|
date: date2
|
|
})
|
|
} : badge : badge;
|
|
}) : [];
|
|
if (c3691_23 != null && c3691_23.userId === userProfile.user.id) {
|
|
if (Date.now() > c3691_23.expiresAtMs) {
|
|
c3691_23 = null;
|
|
} else {
|
|
const r127 = c3691_23;
|
|
if (badges != null) {
|
|
let env15243;
|
|
const r128 = env15243 = {};
|
|
env15243[0] = new Set(badges.map($mk77316()));
|
|
const r138 = r127 == null ? void 0 : r127.badges.filter($mk77317(r128));
|
|
if (r138.length > 0) {
|
|
badges.push.apply(badges, [...r138]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const fetchEndedAt = Date.now();
|
|
const id = userProfile.user.id;
|
|
const r159 = {
|
|
...parseUserProfileCollectibles(userProfile.user_profile),
|
|
userId: userProfile.user.id,
|
|
banner: userProfile.user_profile?.banner,
|
|
accentColor: userProfile.user_profile?.accent_color,
|
|
themeColors: userProfile.user_profile?.theme_colors,
|
|
popoutAnimationParticleType: userProfile.user_profile?.popout_animation_particle_type
|
|
};
|
|
let bio = userProfile.user_profile?.bio;
|
|
if (bio == null) {
|
|
bio = "";
|
|
}
|
|
r159.bio = bio;
|
|
let pronouns = userProfile.user_profile?.pronouns;
|
|
if (pronouns == null) {
|
|
pronouns = "";
|
|
}
|
|
r159.pronouns = pronouns;
|
|
let connectedAccounts = userProfile.connected_accounts.filter((connected_account) => Platforms.isSupported(connected_account.type));
|
|
if (connectedAccounts == null) {
|
|
connectedAccounts = [];
|
|
}
|
|
r159.connectedAccounts = connectedAccounts;
|
|
let application_role_connections = userProfile.application_role_connections;
|
|
if (application_role_connections == null) {
|
|
application_role_connections = [];
|
|
}
|
|
r159.applicationRoleConnections = application_role_connections;
|
|
r159.premiumSince = date;
|
|
r159.premiumType = userProfile.premium_type;
|
|
r159.premiumGuildSince = date2;
|
|
r159.fetchStartedAt = fetchStartedAt;
|
|
r159.fetchEndedAt = fetchEndedAt;
|
|
r159.legacyUsername = userProfile.legacy_username;
|
|
r159.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,
|
|
termsOfServiceUrl: application.terms_of_service_url,
|
|
privacyPolicyUrl: application.privacy_policy_url
|
|
} : null;
|
|
r159.badges = badges;
|
|
const widgets = userProfile.widgets;
|
|
r159.widgets = widgets == null ? void 0 : widgets.map(createUserWidgetFromServer).filter(isNotNullish);
|
|
r159.wishlistSettings = userProfile.wishlist_settings;
|
|
r159.private = userProfile.private;
|
|
c3691_13.set(id, r159);
|
|
checkUserProfileCollectiblesExpiration(userProfile.user.id);
|
|
if (userProfile.guild_member_profile != null) {
|
|
const r226 = {
|
|
...parseUserProfileCollectibles(userProfile.guild_member_profile),
|
|
userId: userProfile.user.id,
|
|
guildId: userProfile.guild_member_profile.guild_id,
|
|
banner: userProfile.guild_member_profile.banner,
|
|
accentColor: userProfile.guild_member_profile.accent_color,
|
|
themeColors: userProfile.guild_member_profile?.theme_colors,
|
|
popoutAnimationParticleType: userProfile.guild_member_profile?.popout_animation_particle_type,
|
|
bio: userProfile.guild_member_profile.bio,
|
|
pronouns: userProfile.guild_member_profile.pronouns,
|
|
badges: userProfile.guild_badges,
|
|
fetchStartedAt,
|
|
fetchEndedAt
|
|
};
|
|
const r256 = c3691_14.get(userProfile.user.id);
|
|
if (r256 != null) {
|
|
r256.set(userProfile.guild_member_profile.guild_id, r226);
|
|
} else {
|
|
const map = new Map();
|
|
map.set(userProfile.guild_member_profile.guild_id, r226);
|
|
c3691_14.set(userProfile.user.id, map);
|
|
}
|
|
checkUserProfileCollectiblesExpiration(userProfile.user.id, userProfile.guild_member_profile.guild_id);
|
|
}
|
|
};
|
|
handleProfileFetchStart = function handleProfileFetchStart(a0) {
|
|
const userId = a0.userId;
|
|
let guildId = a0.guildId;
|
|
const withMutualFriends = a0.withMutualFriends;
|
|
if (guildId == null) {
|
|
guildId = c3691_10;
|
|
}
|
|
const r5 = c3691_11.get(userId);
|
|
if (r5 != null) {
|
|
r5.add(guildId);
|
|
} else {
|
|
const set = new Set();
|
|
set.add(guildId);
|
|
c3691_11.set(userId, set);
|
|
}
|
|
if (withMutualFriends) {
|
|
c3691_12.add(userId);
|
|
}
|
|
};
|
|
handleProfileFetchFailure = function handleProfileFetchFailure({ userId, guildId, apiError, fetchStartedAt }) {
|
|
const r9 = c3691_11.get(userId);
|
|
if (r9 != null) {
|
|
let r14 = guildId;
|
|
if (r14 == null) {
|
|
r14 = c3691_10;
|
|
}
|
|
r9.delete(r14);
|
|
}
|
|
c3691_12.delete(userId);
|
|
let r20 = c3691_13.get(userId);
|
|
if (r20 == null) {
|
|
r20 = {
|
|
connectedAccounts: [],
|
|
applicationRoleConnections: [],
|
|
premiumSince: null,
|
|
premiumGuildSince: null,
|
|
application: null,
|
|
legacyUsername: null,
|
|
userId,
|
|
banner: null,
|
|
accentColor: null,
|
|
bio: "",
|
|
pronouns: "",
|
|
premiumType: null,
|
|
fetchStartedAt: 0,
|
|
fetchEndedAt: 0,
|
|
fetchError: void 0
|
|
};
|
|
}
|
|
const fetchEndedAt = Date.now();
|
|
r20.fetchStartedAt = fetchStartedAt;
|
|
r20.fetchEndedAt = fetchEndedAt;
|
|
r20.fetchError = apiError;
|
|
c3691_13.set(userId, r20);
|
|
if (guildId != null) {
|
|
const r32 = c3691_14.get(userId);
|
|
const r33 = r32 == null ? void 0 : r32.get(guildId);
|
|
if (r33 != null) {
|
|
r33.fetchStartedAt = fetchStartedAt;
|
|
r33.fetchEndedAt = fetchEndedAt;
|
|
r33.fetchError = apiError;
|
|
}
|
|
}
|
|
if (apiError?.status === 404) {
|
|
c3691_17.set(userId, 0);
|
|
c3691_16.set(userId, c3691_19);
|
|
c3691_18.set(userId, c3691_20);
|
|
}
|
|
};
|
|
handleProfileUpdateStart = function handleProfileUpdateStart() {
|
|
c3691_22 = true;
|
|
};
|
|
handleProfileUpdateSuccess = function handleProfileUpdateSuccess(a0) {
|
|
c3691_22 = false;
|
|
if (a0.guild_id != null) {
|
|
const { userId: userId2, guild_id, accent_color: accent_color2, banner: banner2, bio: bio2, pronouns: pronouns2, popout_animation_particle_type: popout_animation_particle_type2, theme_colors: theme_colors2, collectibles: collectibles2 } = a0;
|
|
const r45 = c3691_14.get(userId2);
|
|
if (guild_id != null && r45 != null) {
|
|
const r47 = r45.get(guild_id);
|
|
if (r47 != null) {
|
|
r45.set(guild_id, {
|
|
...r47,
|
|
...parseUserProfileCollectibles({
|
|
collectibles: collectibles2
|
|
}),
|
|
accentColor: accent_color2,
|
|
banner: banner2,
|
|
bio: bio2,
|
|
pronouns: pronouns2,
|
|
popoutAnimationParticleType: popout_animation_particle_type2,
|
|
themeColors: theme_colors2
|
|
});
|
|
checkUserProfileCollectiblesExpiration(userId2, guild_id);
|
|
}
|
|
}
|
|
} else {
|
|
const { userId, accent_color, banner, bio, pronouns, popout_animation_particle_type, theme_colors, collectibles } = a0;
|
|
const r15 = c3691_13.get(userId);
|
|
if (r15 != null) {
|
|
c3691_13.set(userId, {
|
|
...r15,
|
|
...parseUserProfileCollectibles({
|
|
collectibles
|
|
}),
|
|
accentColor: accent_color,
|
|
banner,
|
|
bio,
|
|
pronouns,
|
|
popoutAnimationParticleType: popout_animation_particle_type,
|
|
themeColors: theme_colors
|
|
});
|
|
checkUserProfileCollectiblesExpiration(userId);
|
|
}
|
|
}
|
|
};
|
|
handleProfileUpdateFailure = function handleProfileUpdateFailure() {
|
|
c3691_22 = false;
|
|
};
|
|
handleWidgetsUpdateSuccess = function handleWidgetsUpdateSuccess({ userId, widgets }) {
|
|
const r6 = c3691_13.get(userId);
|
|
if (r6 == null) {
|
|
return false;
|
|
}
|
|
c3691_13.set(userId, {
|
|
...r6,
|
|
widgets: widgets.map(createUserWidgetFromServer).filter(isNotNullish)
|
|
});
|
|
};
|
|
handlePinBadgesToProfile = function handlePinBadgesToProfile({ badges, ttlInSeconds, userId }) {
|
|
c3691_23 = {
|
|
userId,
|
|
badges,
|
|
expiresAtMs: Date.now() + 1000 * ttlInSeconds
|
|
};
|
|
const r23 = c3691_13.get(userId);
|
|
if (r23 != null) {
|
|
let badges2 = r23.badges;
|
|
if (badges2 == null) {
|
|
badges2 = [];
|
|
}
|
|
const r25 = c3691_23;
|
|
if (badges2 != null) {
|
|
let env15244;
|
|
const r26 = env15244 = {};
|
|
const r11 = Set;
|
|
const map = badges2.map;
|
|
let r27 = void 0;
|
|
env15244[0] = new r11(map.call(badges2, $mk77316()));
|
|
if (r25 != null) {
|
|
r27 = r25.badges.filter($mk77317(r26));
|
|
}
|
|
if (r27.length > 0) {
|
|
badges2.push.apply(badges2, [...r27]);
|
|
}
|
|
}
|
|
c3691_13.set(userId, {
|
|
...r23,
|
|
badges: badges2
|
|
});
|
|
}
|
|
};
|
|
handleUserUpdate = function handleUserUpdate(a0) {
|
|
const id = a0.user.id;
|
|
let r10 = c3691_11.get(id)?.size;
|
|
if (r10 == null) {
|
|
r10 = 0;
|
|
}
|
|
return !(r10 > 0) && resetProfileFetch(id);
|
|
};
|
|
handleGuildStatusChange = function handleGuildStatusChange() {
|
|
return [...c3691_13.keys()].reduce((acc, item) => resetProfileFetch(item) || acc, false);
|
|
};
|
|
handleGuildMemberStatusChange = function handleGuildMemberStatusChange(a0) {
|
|
return resetProfileFetch(a0.user.id);
|
|
};
|
|
handleRelationshipStatusChange = function handleRelationshipStatusChange(a0) {
|
|
return resetProfileFetch(a0.relationship.id);
|
|
};
|
|
handleLocaleStoreChange = function handleLocaleStoreChange() {
|
|
c3691_11.clear();
|
|
c3691_12.clear();
|
|
c3691_13.clear();
|
|
c3691_14.clear();
|
|
};
|
|
resetProfileFetch = function resetProfileFetch(id) {
|
|
if (id == null) {
|
|
return false;
|
|
}
|
|
const r4 = c3691_13.get(id);
|
|
if (r4 == null) {
|
|
return false;
|
|
}
|
|
r4.fetchStartedAt = 0;
|
|
r4.fetchEndedAt = 0;
|
|
r4.fetchError = void 0;
|
|
const r21 = c3691_14.get(id);
|
|
if (r21 != null) {
|
|
for (const item of r21.values()) {
|
|
item.fetchStartedAt = 0;
|
|
item.fetchEndedAt = 0;
|
|
item.fetchError = void 0;
|
|
}
|
|
}
|
|
};
|
|
c3691_10 = Symbol("NO GUILD ID");
|
|
c3691_11 = new Map();
|
|
c3691_12 = new Set();
|
|
c3691_13 = new Map();
|
|
c3691_14 = new Map();
|
|
c3691_15 = {};
|
|
c3691_16 = new Map();
|
|
c3691_17 = new Map();
|
|
c3691_18 = new Map();
|
|
c3691_19 = [];
|
|
c3691_20 = [];
|
|
c3691_22 = false;
|
|
c3691_23 = null;
|
|
class UserProfileStore extends MobileCacheSnapshotStore {
|
|
static displayName = "UserProfileStore";
|
|
static LATEST_SNAPSHOT_VERSION = 1;
|
|
constructor() {
|
|
let c15246_0;
|
|
const r9 = {
|
|
CACHE_LOADED_LAZY: () => this.loadCache(),
|
|
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,
|
|
GUILD_MEMBER_UPDATE: handleUserUpdate,
|
|
GUILD_JOIN: handleGuildStatusChange,
|
|
GUILD_DELETE: handleGuildStatusChange,
|
|
INVITE_ACCEPT_SUCCESS: handleGuildStatusChange,
|
|
GUILD_MEMBER_ADD: handleGuildMemberStatusChange,
|
|
GUILD_MEMBER_REMOVE: handleGuildMemberStatusChange,
|
|
RELATIONSHIP_ADD: handleRelationshipStatusChange,
|
|
RELATIONSHIP_REMOVE: handleRelationshipStatusChange,
|
|
RELATIONSHIP_UPDATE: handleRelationshipStatusChange,
|
|
LOGOUT: handleLogout
|
|
};
|
|
super(r9);
|
|
c15246_0 = this;
|
|
this.loadCache = () => {
|
|
const r7 = c15246_0.readSnapshot(UserProfileStore.LATEST_SNAPSHOT_VERSION);
|
|
if (r7 != null) {
|
|
r7.forEach(({ userId, profile }) => {
|
|
if (userId != null) {
|
|
if (profile != null) {
|
|
c3691_13.set(userId, profile);
|
|
} else {
|
|
c3691_13.delete(userId);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
initialize() {
|
|
this.waitFor(SortedGuildStore);
|
|
this.syncWith([LocaleStore], handleLocaleStoreChange);
|
|
}
|
|
isFetchingProfile(a0, a1) {
|
|
const r4 = c3691_11.get(a0);
|
|
return r4 != null && r4.has(a1 == null ? c3691_10 : a1);
|
|
}
|
|
isFetchingFriends(a0) {
|
|
return c3691_12.has(a0);
|
|
}
|
|
get isSubmitting() {
|
|
return c3691_22;
|
|
}
|
|
getUserProfile(a0) {
|
|
return c3691_13.get(a0);
|
|
}
|
|
getGuildMemberProfile(a0, a1) {
|
|
const r1 = a1 == null;
|
|
let r2 = null;
|
|
if (!r1) {
|
|
const r8 = c3691_14.get(a0);
|
|
let r10 = r8 == null ? void 0 : r8.get(a1);
|
|
if (r10 == null) {
|
|
r10 = null;
|
|
}
|
|
r2 = r10;
|
|
}
|
|
return r2;
|
|
}
|
|
getMutualFriends(a0) {
|
|
return c3691_16.get(a0);
|
|
}
|
|
getMutualFriendsCount(a0) {
|
|
return c3691_17.get(a0);
|
|
}
|
|
getMutualGuilds(a0) {
|
|
return c3691_18.get(a0);
|
|
}
|
|
getWidgets(a0) {
|
|
return c3691_13.get(a0)?.widgets;
|
|
}
|
|
getWishlistIds(a0) {
|
|
const r7 = c3691_13.get(a0);
|
|
return r7?.wishlistSettings != null ? Object.keys(r7.wishlistSettings) : [];
|
|
}
|
|
getFirstWishlistId(a0) {
|
|
if (a0 == null) {
|
|
return null;
|
|
}
|
|
const wishlistIds = this.getWishlistIds(a0);
|
|
return wishlistIds.length > 0 ? wishlistIds[0] : null;
|
|
}
|
|
getWishlistSettings(a0, a1) {
|
|
const r7 = c3691_13.get(a0);
|
|
const r2 = r7 == null;
|
|
let r8 = void 0;
|
|
if (!r2) {
|
|
const wishlistSettings = r7.wishlistSettings;
|
|
r8 = wishlistSettings == null ? void 0 : wishlistSettings[a1];
|
|
}
|
|
if (r8 == null) {
|
|
r8 = null;
|
|
}
|
|
return r8;
|
|
}
|
|
takeSnapshot() {
|
|
const id = AuthenticationStore.getId();
|
|
const profile = c3691_13.get(id);
|
|
return profile != null ? {
|
|
version: UserProfileStore.LATEST_SNAPSHOT_VERSION,
|
|
data: [{
|
|
userId: id,
|
|
profile
|
|
}]
|
|
} : {
|
|
version: UserProfileStore.LATEST_SNAPSHOT_VERSION,
|
|
data: []
|
|
};
|
|
}
|
|
}
|
|
c3691_43 = new UserProfileStore();
|
|
export default c3691_43;
|