fix plugins for latest discord update (#3387)

Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
sadan4 2025-04-23 14:36:43 -04:00 committed by GitHub
parent e99e89e964
commit cf78ddcfe2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 44 additions and 46 deletions

View file

@ -9,7 +9,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { getCurrentChannel } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
import { findComponentByCodeLazy } from "@webpack";
import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common";
import { User } from "discord-types/general";
@ -19,8 +19,7 @@ interface UserProfileProps {
originalRenderPopout: () => React.ReactNode;
}
const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined");
const styles = findByPropsLazy("accountProfilePopoutWrapper");
const UserProfile = findComponentByCodeLazy(".POPOUT,user");
let openAlternatePopout = false;
let accountPanelRef: React.RefObject<Record<PropertyKey, any> | null> = { current: null };
@ -77,7 +76,7 @@ export default definePlugin({
replace: "$self.useAccountPanelRef();$&"
},
{
match: /(\.AVATAR,children:.+?renderPopout:(\(\i,\i\))=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
match: /(\.AVATAR,children:.+?renderPopout:\((\i),\i\)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})`
},
{
@ -121,14 +120,18 @@ export default definePlugin({
}
const currentChannel = getCurrentChannel();
if (currentChannel?.getGuildId() == null) {
if (currentChannel?.getGuildId() == null || !UserProfile.$$vencordGetWrappedComponent()) {
return originalRenderPopout();
}
return (
<div className={styles.accountProfilePopoutWrapper}>
<UserProfile {...popoutProps} userId={currentUser.id} guildId={currentChannel.getGuildId()} channelId={currentChannel.id} />
</div>
<UserProfile
{...popoutProps}
user={currentUser}
currentUser={currentUser}
guildId={currentChannel.getGuildId()}
channelId={currentChannel.id}
/>
);
}, { noop: true })
});