From 72329f901cae0e45feb24d9ff38eb2eb8d3756d0 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Mon, 11 Aug 2025 21:28:19 -0400 Subject: [PATCH] AccountPanelServerProfile: fix right click menu (#3600) Co-authored-by: Vendicated --- .../accountPanelServerProfile/index.tsx | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index ce9f6b51..57144ec0 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -11,7 +11,7 @@ import { getCurrentChannel } from "@utils/discord"; import definePlugin, { OptionType } from "@utils/types"; import { User } from "@vencord/discord-types"; import { findComponentByCodeLazy } from "@webpack"; -import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common"; +import { ContextMenuApi, Menu } from "@webpack/common"; interface UserProfileProps { popoutProps: Record; @@ -22,7 +22,7 @@ interface UserProfileProps { const UserProfile = findComponentByCodeLazy(".POPOUT,user"); let openAlternatePopout = false; -let accountPanelRef: React.RefObject | null> = { current: null }; +let accountPanelRef: React.RefObject = { current: null }; const AccountPanelContextMenu = ErrorBoundary.wrap(() => { const { prioritizeServerProfile } = settings.use(["prioritizeServerProfile"]); @@ -38,8 +38,7 @@ const AccountPanelContextMenu = ErrorBoundary.wrap(() => { disabled={getCurrentChannel()?.getGuildId() == null} action={e => { openAlternatePopout = true; - accountPanelRef.current?.props.onMouseDown(); - accountPanelRef.current?.props.onClick(e); + accountPanelRef.current?.click(); }} /> ){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/, replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})` @@ -84,8 +79,8 @@ export default definePlugin({ replace: "$&$self.onPopoutClose();" }, { - match: /(?<=#{intl::SET_STATUS}\),)/, - replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu," + match: /#{intl::SET_STATUS}\)(?<=innerRef:(\i),style:.+?)/, + replace: "$&,onContextMenu:($self.grabRef($1),$self.openAccountPanelContextMenu)" } ] } @@ -95,12 +90,9 @@ export default definePlugin({ return accountPanelRef; }, - useAccountPanelRef() { - useEffect(() => () => { - accountPanelRef.current = null; - }, []); - - return (accountPanelRef = useRef(null)); + grabRef(ref: React.RefObject) { + accountPanelRef = ref; + return ref; }, openAccountPanelContextMenu(event: React.UIEvent) {