From 2478ffb695ee4e8225eb3dee7bc8dd57ee1ad4db Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 21:57:50 +0700 Subject: [PATCH] fix userutils (#1861) --- src/components/PluginSettings/PluginModal.tsx | 2 +- src/plugins/relationshipNotifier/functions.ts | 2 +- src/plugins/relationshipNotifier/utils.ts | 4 ++-- src/plugins/serverProfile/GuildProfileModal.tsx | 2 +- src/utils/discord.tsx | 2 +- src/webpack/common/utils.ts | 6 ++---- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index d8b949066..03789ac6c 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -94,7 +94,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti (async () => { for (const user of plugin.authors.slice(0, 6)) { const author = user.id - ? await UserUtils.fetchUser(`${user.id}`) + ? await UserUtils.getUser(`${user.id}`) .catch(() => makeDummyUser({ username: user.name })) : makeDummyUser({ username: user.name }); diff --git a/src/plugins/relationshipNotifier/functions.ts b/src/plugins/relationshipNotifier/functions.ts index e712382b5..980b11300 100644 --- a/src/plugins/relationshipNotifier/functions.ts +++ b/src/plugins/relationshipNotifier/functions.ts @@ -37,7 +37,7 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat return; } - const user = await UserUtils.fetchUser(id) + const user = await UserUtils.getUser(id) .catch(() => null); if (!user) return; diff --git a/src/plugins/relationshipNotifier/utils.ts b/src/plugins/relationshipNotifier/utils.ts index 5de9d75a7..16f1892af 100644 --- a/src/plugins/relationshipNotifier/utils.ts +++ b/src/plugins/relationshipNotifier/utils.ts @@ -68,7 +68,7 @@ export async function syncAndRunChecks() { for (const id of oldFriends.friends) { if (friends.friends.includes(id)) continue; - const user = await UserUtils.fetchUser(id).catch(() => void 0); + const user = await UserUtils.getUser(id).catch(() => void 0); if (user) notify( `You are no longer friends with ${getUniqueUsername(user)}.`, @@ -85,7 +85,7 @@ export async function syncAndRunChecks() { [RelationshipType.FRIEND, RelationshipType.BLOCKED, RelationshipType.OUTGOING_REQUEST].includes(RelationshipStore.getRelationshipType(id)) ) continue; - const user = await UserUtils.fetchUser(id).catch(() => void 0); + const user = await UserUtils.getUser(id).catch(() => void 0); if (user) notify( `Friend request from ${getUniqueUsername(user)} has been revoked.`, diff --git a/src/plugins/serverProfile/GuildProfileModal.tsx b/src/plugins/serverProfile/GuildProfileModal.tsx index 2be9b57d9..2a7958a10 100644 --- a/src/plugins/serverProfile/GuildProfileModal.tsx +++ b/src/plugins/serverProfile/GuildProfileModal.tsx @@ -162,7 +162,7 @@ function Owner(guildId: string, owner: User) { } function ServerInfoTab({ guild }: GuildProps) { - const [owner] = useAwaiter(() => UserUtils.fetchUser(guild.ownerId), { + const [owner] = useAwaiter(() => UserUtils.getUser(guild.ownerId), { deps: [guild.ownerId], fallbackValue: null }); diff --git a/src/utils/discord.tsx b/src/utils/discord.tsx index 458509b42..a36ecfbb9 100644 --- a/src/utils/discord.tsx +++ b/src/utils/discord.tsx @@ -103,7 +103,7 @@ export function openImageModal(url: string, props?: Partial Promise, -}; +export const UserUtils = findByPropsLazy("getUser", "fetchCurrentUser") as { getUser: (id: string) => Promise; }; export const Clipboard = mapMangledModuleLazy('document.queryCommandEnabled("copy")||document.queryCommandSupported("copy")', { copy: filters.byCode(".copy("),