decord/source/modules/user_profile/maybeFetchUserProfile.tsx
2026-08-13 07:00:46 +00:00

179 lines
5.1 KiB
TypeScript

// Module ID: 8356
// Function ID: 8357
// Name: maybeFetchUserProfile
// Dependencies: [1391, 1990, 7128, 7048, 8282, 5165, 709, 8357, 8358, 2]
// Exports: default
// Module 8356 (maybeFetchUserProfile)
import ensureGuildLoaded from "ensureGuildLoaded";
import trackCommunicationDisabled from "trackCommunicationDisabled";
import createUserWidgetFromServer from "createUserWidgetFromServer";
const require = arg1;
let result = require("createUserWidgetFromServer").fileFinishedImporting("modules/user_profile/maybeFetchUserProfile.tsx");
export default function maybeFetchUserProfile(id, closure_0, guildMember) {
let type;
let withMutualGuilds;
const _require = id;
let obj = guildMember;
if (guildMember === undefined) {
obj = {};
}
({ withMutualGuilds, type } = obj);
if (withMutualGuilds === undefined) {
withMutualGuilds = false;
}
let flag = obj.withMutualFriendsCount;
if (flag === undefined) {
flag = false;
}
let flag2 = obj.withMutualFriends;
if (flag2 === undefined) {
flag2 = false;
}
let flag3 = obj.dispatchWait;
if (flag3 === undefined) {
flag3 = false;
}
let flag4 = obj.waitForRefetch;
if (flag4 === undefined) {
flag4 = true;
}
const guildId = obj.guildId;
obj = undefined;
if ("" === id) {
return Promise.resolve();
} else if (fetchingProfile.isFetchingProfile(id, guildId)) {
return Promise.resolve();
} else {
const userProfile = obj10.getUserProfile(id);
const guildMemberProfile = obj10.getGuildMemberProfile(id, guildId);
let tmp7 = userProfile;
if (null != guildId) {
tmp7 = guildMemberProfile;
}
const _Date = Date;
let num;
const timestamp = Date.now();
if (tmp7 != null) {
num = tmp7.fetchEndedAt;
}
if (num == null) {
num = 0;
}
let status;
const diff = timestamp - num;
if (tmp7 != null) {
const fetchError = tmp7.fetchError;
if (fetchError != null) {
status = fetchError.status;
}
}
let tmp12 = diff >= 60000;
if (404 === status) {
if (!tmp12) {
return Promise.resolve();
}
} else {
let status1;
if (tmp7 != null) {
const fetchError2 = tmp7.fetchError;
if (fetchError2 != null) {
status1 = fetchError2.status;
}
}
}
const mutualGuilds = obj10.getMutualGuilds(id);
const mutualFriends = obj10.getMutualFriends(id);
const tmp17 = null == guildId ? null == userProfile : null == guildMemberProfile;
let tmp18 = !tmp17;
if (!tmp17) {
if (!tmp12) {
tmp12 = null == mutualGuilds && withMutualGuilds;
const tmp19 = null == mutualGuilds && withMutualGuilds;
}
if (!tmp12) {
tmp12 = null == mutualFriends && flag2;
const tmp20 = null == mutualFriends && flag2;
}
if (!tmp12) {
tmp12 = null == tmp16 && flag;
const tmp21 = null == tmp16 && flag;
}
tmp18 = tmp12;
}
if (!tmp17) {
if (!tmp18) {
return Promise.resolve();
}
}
if (null != guildId) {
let profileEffect;
if (guildMemberProfile != null) {
profileEffect = guildMemberProfile.profileEffect;
}
} else if (userProfile != null) {
profileEffect = userProfile.profileEffect;
}
if (null != profileEffect) {
const result = _require(7048).maybeFetchCollectiblesProduct(profileEffect.skuId);
const obj2 = _require(7048);
}
if (null != guildId) {
let profileFrame;
if (guildMemberProfile != null) {
profileFrame = guildMemberProfile.profileFrame;
}
} else if (userProfile != null) {
profileFrame = userProfile.profileFrame;
}
if (null != profileFrame) {
const result1 = _require(7048).maybeFetchCollectiblesProduct(profileFrame.skuId);
const obj3 = _require(7048);
}
if (null != closure_0) {
_require(8282).maybeFetchColors(closure_0);
const obj4 = _require(8282);
}
obj = { type: null, withMutualGuilds: null, withMutualFriends: null, withMutualFriendsCount: null, guildId: null, joinRequestId: null, abortSignal: null, connectionsRoleId: null };
obj[0] = type;
obj[1] = withMutualGuilds;
obj[2] = flag2;
obj[3] = flag;
obj[4] = guildId;
obj[5] = tmp2;
obj[6] = tmp3;
let tmp34;
if (null != guildId) {
obj = { guildMember: null, channel: null };
obj[0] = member.getMember(guildId, id);
obj[1] = channel.getChannel(tmp);
const visibleConnectionsRole = _require(5165).getVisibleConnectionsRole(obj);
id = undefined;
if (visibleConnectionsRole != null) {
id = visibleConnectionsRole.id;
}
tmp34 = id;
const obj6 = _require(5165);
}
obj[7] = tmp34;
if (flag3) {
obj(709).wait(() => {
const obj = id(outer1_2[7]);
return obj.fetchProfile(id, obj, obj(outer1_2[8]));
});
return Promise.resolve();
} else {
const profile = _require(8357).fetchProfile(id, obj, obj(8358));
let resolved = profile;
if (tmp18) {
resolved = profile;
if (!flag4) {
resolved = Promise.resolve();
}
}
return resolved;
}
}
};