diff --git a/src/equicordplugins/alwaysExpandProfiles/index.ts b/src/equicordplugins/alwaysExpandProfiles/index.ts index e7fa58419..c78baea4f 100644 --- a/src/equicordplugins/alwaysExpandProfiles/index.ts +++ b/src/equicordplugins/alwaysExpandProfiles/index.ts @@ -7,7 +7,6 @@ import { Devs } from "@utils/constants"; import { openUserProfile } from "@utils/discord"; import definePlugin from "@utils/types"; -import { User } from "@vencord/discord-types"; export default definePlugin({ name: "AlwaysExpandProfiles", @@ -17,13 +16,13 @@ export default definePlugin({ { find: '"view-profile"', replacement: { - match: /(user:(\i).*?"PRESS_VIEW_PROFILE".{0,200}return)/, - replace: "$1 $self.openUserModal($2);" + match: /("PRESS_VIEW_PROFILE".{0,200})return(?<=userId:(\i\.id).*?)/, + replace: "$1return $self.openUserModal($2);" }, all: true }, ], - openUserModal(user: User) { - openUserProfile(user.id); + openUserModal(userId: string) { + openUserProfile(userId); } }); diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index cbf23bbab..0d2fc2c35 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -9,7 +9,7 @@ import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import alwaysExpandProfiles from "@equicordplugins/alwaysExpandProfiles"; import { Devs } from "@utils/constants"; -import { getCurrentChannel } from "@utils/discord"; +import { fetchUserProfile, getCurrentChannel } from "@utils/discord"; import definePlugin, { OptionType } from "@utils/types"; import { User } from "@vencord/discord-types"; import { findComponentByCodeLazy } from "@webpack"; @@ -38,10 +38,12 @@ const AccountPanelContextMenu = ErrorBoundary.wrap(() => { id="vc-ap-view-alternate-popout" label={prioritizeServerProfile ? "View Account Profile" : "View Server Profile"} disabled={getCurrentChannel()?.getGuildId() == null} - action={e => { + action={async e => { if (isPluginEnabled(alwaysExpandProfiles.name)) { - const user = UserStore.getCurrentUser(); - return alwaysExpandProfiles.openUserModal(user); + const user = await fetchUserProfile(UserStore.getCurrentUser().id, { + guild_id: getCurrentChannel()?.getGuildId() + }, false); + return alwaysExpandProfiles.openUserModal(user!.userId); } openAlternatePopout = true; accountPanelRef.current?.click(); diff --git a/src/utils/discord.tsx b/src/utils/discord.tsx index 08c9c3497..ca79fc77a 100644 --- a/src/utils/discord.tsx +++ b/src/utils/discord.tsx @@ -207,9 +207,9 @@ interface FetchUserProfileOptions { /** * Fetch a user's profile */ -export async function fetchUserProfile(id: string, options?: FetchUserProfileOptions) { +export async function fetchUserProfile(id: string, options?: FetchUserProfileOptions, cache = true) { const cached = UserProfileStore.getUserProfile(id); - if (cached) return cached; + if (cached && cache) return cached; FluxDispatcher.dispatch({ type: "USER_PROFILE_FETCH_START", userId: id });