From 44c84634960bb6c1695c4681f49fff878c48bbab Mon Sep 17 00:00:00 2001 From: v Date: Thu, 22 Aug 2024 17:13:57 +0200 Subject: [PATCH] Remove obsolete patches for old profiles (#2800) Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> --- src/plugins/_api/badges/index.tsx | 28 --------- src/plugins/betterNotes/index.tsx | 18 ------ src/plugins/friendsSince/index.tsx | 62 +------------------ src/plugins/moreUserTags/index.tsx | 4 +- src/plugins/mutualGroupDMs/index.tsx | 17 ----- src/plugins/noProfileThemes/index.ts | 9 --- src/plugins/permissionsViewer/index.tsx | 10 --- src/plugins/pronoundb/index.ts | 24 +------ src/plugins/reviewDB/index.tsx | 36 +---------- src/plugins/showConnections/index.tsx | 62 +++---------------- .../components/VoiceChannelSection.tsx | 8 +-- src/plugins/userVoiceShow/index.tsx | 20 +----- src/plugins/viewIcons/index.tsx | 16 ----- 13 files changed, 23 insertions(+), 291 deletions(-) diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index 89a992ac3..cf00a0e29 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -62,34 +62,6 @@ export default definePlugin({ authors: [Devs.Megu, Devs.Ven, Devs.TheSun], required: true, patches: [ - /* Patch the badge list component on user profiles */ - { - find: 'id:"premium",', - replacement: [ - { - match: /&&(\i)\.push\(\{id:"premium".+?\}\);/, - replace: "$&$1.unshift(...$self.getBadges(arguments[0]));", - }, - { - // alt: "", aria-hidden: false, src: originalSrc - match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/, - // ...badge.props, ..., src: badge.image ?? ... - replace: "...$1.props,$& $1.image??" - }, - // replace their component with ours if applicable - { - match: /(?<=text:(\i)\.description,spacing:12,.{0,50})children:/, - replace: "children:$1.component ? () => $self.renderBadgeComponent($1) :" - }, - // conditionally override their onClick with badge.onClick if it exists - { - match: /href:(\i)\.link/, - replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&" - } - ] - }, - - /* new profiles */ { find: ".FULL_SIZE]:26", replacement: { diff --git a/src/plugins/betterNotes/index.tsx b/src/plugins/betterNotes/index.tsx index b97076bf4..63fcf6477 100644 --- a/src/plugins/betterNotes/index.tsx +++ b/src/plugins/betterNotes/index.tsx @@ -17,13 +17,9 @@ */ import { definePluginSettings, Settings } from "@api/Settings"; -import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { canonicalizeMatch } from "@utils/patches"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy } from "@webpack"; - -const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection"); const settings = definePluginSettings({ hide: { @@ -72,23 +68,9 @@ export default definePlugin({ match: /\.NOTE_PLACEHOLDER,/, replace: "$&spellCheck:!$self.noSpellCheck," } - }, - { - find: ".popularApplicationCommandIds,", - replacement: { - match: /lastSection:(!?\i)}\),/, - replace: "$&$self.patchPadding({lastSection:$1})," - } } ], - patchPadding: ErrorBoundary.wrap(({ lastSection }) => { - if (!lastSection) return null; - return ( -
- ); - }), - get noSpellCheck() { return settings.store.noSpellCheck; } diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index 717bd754c..0399a2f72 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -16,7 +16,6 @@ const containerWrapper = findByPropsLazy("memberSinceWrapper"); const container = findByPropsLazy("memberSince"); const getCreatedAtDate = findByCodeLazy('month:"short",day:"numeric"'); const locale = findByPropsLazy("getLocale"); -const lastSection = findByPropsLazy("lastSection"); const section = findLazy((m: any) => m.section !== void 0 && m.heading !== void 0 && Object.values(m).length === 2); export default definePlugin({ @@ -24,31 +23,7 @@ export default definePlugin({ description: "Shows when you became friends with someone in the user popout", authors: [Devs.Elvyra, Devs.Antti], patches: [ - // User popup - old layout - { - find: ".USER_PROFILE}};return", - replacement: { - match: /,{userId:(\i.id).{0,30}}\)/, - replace: "$&,$self.friendsSinceOld({ userId: $1 })" - } - }, - // DM User Sidebar - old layout - { - find: ".PROFILE_PANEL,", - replacement: { - match: /,{userId:([^,]+?)}\)/, - replace: "$&,$self.friendsSinceOld({ userId: $1 })" - } - }, - // User Profile Modal - old layout - { - find: ".userInfoSectionHeader,", - replacement: { - match: /(\.Messages\.USER_PROFILE_MEMBER_SINCE.+?userId:(.+?),textClassName:)(\i\.userInfoText)}\)/, - replace: (_, rest, userId, textClassName) => `${rest}!$self.getFriendSince(${userId}) ? ${textClassName} : void 0 }), $self.friendsSinceOld({ userId: ${userId}, textClassName: ${textClassName} })` - } - }, - // DM User Sidebar - new layout + // DM User Sidebar { find: ".PANEL}),nicknameIcons", replacement: { @@ -56,7 +31,7 @@ export default definePlugin({ replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:true})" } }, - // User Profile Modal - new layout + // User Profile Modal { find: "action:\"PRESS_APP_CONNECTION\"", replacement: { @@ -77,39 +52,6 @@ export default definePlugin({ } }, - friendsSinceOld: ErrorBoundary.wrap(({ userId, textClassName }: { userId: string; textClassName?: string; }) => { - if (!RelationshipStore.isFriend(userId)) return null; - - const friendsSince = RelationshipStore.getSince(userId); - if (!friendsSince) return null; - - return ( -
- - Friends Since - - -
- {!!getCurrentChannel()?.guild_id && ( - - )} - - {getCreatedAtDate(friendsSince, locale.getLocale())} - -
-
- ); - }, { noop: true }), - friendsSinceNew: ErrorBoundary.wrap(({ userId, isSidebar }: { userId: string; isSidebar: boolean; }) => { if (!RelationshipStore.isFriend(userId)) return null; diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 45538fb66..4802f04a1 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -247,9 +247,9 @@ export default definePlugin({ } }, { - find: 'copyMetaData:"User Tag"', + find: ".Messages.USER_PROFILE_PRONOUNS", replacement: { - match: /(?=,botClass:)/, + match: /(?=,hideBotTag:!0)/, replace: ",moreTags_channelId:arguments[0].moreTags_channelId" } }, diff --git a/src/plugins/mutualGroupDMs/index.tsx b/src/plugins/mutualGroupDMs/index.tsx index 7c71e1edb..a1e73cabf 100644 --- a/src/plugins/mutualGroupDMs/index.tsx +++ b/src/plugins/mutualGroupDMs/index.tsx @@ -58,20 +58,6 @@ export default definePlugin({ authors: [Devs.amia], patches: [ - { - find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Note: the module is lazy-loaded - replacement: { - match: /(?<=\.tabBarItem.{0,50}MUTUAL_GUILDS.+?}\),)(?=.+?(\(0,\i\.jsxs?\)\(.{0,100}id:))/, - replace: '$self.isBotOrSelf(arguments[0].user)?null:$1"MUTUAL_GDMS",children:$self.getMutualGDMCountText(arguments[0].user)}),' - } - }, - { - find: ".USER_INFO_CONNECTIONS:case", - replacement: { - match: /(?<={user:(\i),onClose:(\i)}\);)(?=case \i\.\i\.MUTUAL_FRIENDS)/, - replace: "case \"MUTUAL_GDMS\":return $self.renderMutualGDMs({user: $1, onClose: $2});" - } - }, { find: ".MUTUAL_FRIENDS?(", replacement: [ @@ -87,9 +73,6 @@ export default definePlugin({ } ], - isBotOrSelf, - getMutualGDMCountText, - pushSection(sections: any[], user: User) { if (isBotOrSelf(user) || sections[IS_PATCHED]) return; diff --git a/src/plugins/noProfileThemes/index.ts b/src/plugins/noProfileThemes/index.ts index e2b9327e8..2cb83cc72 100644 --- a/src/plugins/noProfileThemes/index.ts +++ b/src/plugins/noProfileThemes/index.ts @@ -33,15 +33,6 @@ export default definePlugin({ replace: "=(arguments[0]?.bannerSrc||$1?.banner)&&" } }, - { - find: ".avatarPositionPremiumNoBanner,default:", - replacement: { - // premiumUserWithoutBanner: foo().avatarPositionPremiumNoBanner, default: foo().avatarPositionNormal - match: /\.avatarPositionPremiumNoBanner(?=,default:\i\.(\i))/, - // premiumUserWithoutBanner: foo().avatarPositionNormal... - replace: ".$1" - } - }, { find: "hasThemeColors(){", replacement: { diff --git a/src/plugins/permissionsViewer/index.tsx b/src/plugins/permissionsViewer/index.tsx index 6a503f2da..1bb8ea194 100644 --- a/src/plugins/permissionsViewer/index.tsx +++ b/src/plugins/permissionsViewer/index.tsx @@ -169,13 +169,6 @@ export default definePlugin({ settings, patches: [ - { - find: ".popularApplicationCommandIds,", - replacement: { - match: /showBorder:(.{0,60})}\),(?<=guild:(\i),guildMember:(\i),.+?)/, - replace: (m, showBoder, guild, guildMember) => `${m}$self.UserPermissions(${guild},${guildMember},${showBoder}),` - } - }, { find: ".VIEW_ALL_ROLES,", replacement: { @@ -185,9 +178,6 @@ export default definePlugin({ } ], - UserPermissions: (guild: Guild, guildMember: GuildMember | undefined, showBorder: boolean) => - !!guildMember && , - ViewPermissionsButton: ErrorBoundary.wrap(({ guild, guildMember }: { guild: Guild; guildMember: GuildMember; }) => ( { - const [reviewCount, setReviewCount] = useState(); - - return ( - openReviewsModal(user.id, user.username)} - moreTooltipText={ - reviewCount && reviewCount > 50 - ? `View all ${reviewCount} reviews` - : "Open Review Modal" - } - onDropDownClick={state => settings.store.reviewsDropdownState = !state} - defaultState={settings.store.reviewsDropdownState} - > - setReviewCount(r.reviewCount)} - showInput - /> - - ); - }, { message: "Failed to render Reviews" }), - BiteSizeReviewsButton: ErrorBoundary.wrap(({ user }: { user: User; }) => { return ( diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index f9f3d9eb7..d712027e3 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -25,15 +25,12 @@ import { CopyIcon, LinkIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; import { copyWithToast } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Text, Tooltip, UserProfileStore } from "@webpack/common"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { Tooltip, UserProfileStore } from "@webpack/common"; import { User } from "discord-types/general"; import { VerifiedIcon } from "./VerifiedIcon"; -const Section = findComponentByCodeLazy(".lastSection", "children:"); -const ThemeStore = findStoreLazy("ThemeStore"); - const useLegacyPlatformType: (platform: string) => string = findByCodeLazy(".TWITTER_LEGACY:"); const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl"); const getProfileThemeProps = findByCodeLazy(".getPreviewThemeColors", "primaryColor:"); @@ -76,7 +73,7 @@ interface ConnectionPlatform { } const profilePopoutComponent = ErrorBoundary.wrap( - (props: { user: User; displayProfile?: any; simplified?: boolean; }) => ( + (props: { user: User; displayProfile?: any; }) => ( ( - - ), - { noop: true } -); - -function ConnectionsComponent({ id, theme, simplified }: { id: string, theme: string, simplified?: boolean; }) { +function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) { const profile = UserProfileStore.getUserProfile(id); if (!profile) return null; @@ -105,31 +92,14 @@ function ConnectionsComponent({ id, theme, simplified }: { id: string, theme: st if (!connections?.length) return null; - const connectionsContainer = ( + return ( {connections.map(connection => )} ); - - if (simplified) - return connectionsContainer; - - return ( -
- - Connections - - {connectionsContainer} -
- ); } function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) { @@ -194,31 +164,17 @@ export default definePlugin({ name: "ShowConnections", description: "Show connected accounts in user popouts", authors: [Devs.TheKodeToad], + settings, + patches: [ - { - find: "{isUsingGuildBio:null!==(", - replacement: { - match: /,theme:\i\}\)(?=,.{0,150}setNote:)/, - replace: "$&,$self.profilePopoutComponent({ user: arguments[0].user, displayProfile: arguments[0].displayProfile })" - } - }, - { - find: ".PROFILE_PANEL,", - replacement: { - // createElement(Divider, {}), createElement(NoteComponent) - match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/, - replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&" - } - }, { find: '"BiteSizeProfileBody"', replacement: { match: /currentUser:\i,guild:\i}\)(?<=user:(\i),bio:null==(\i)\?.+?)/, - replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2, simplified: true })" + replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2 })" } } ], - settings, + profilePopoutComponent, - profilePanelComponent }); diff --git a/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx b/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx index c1bcbd657..8ca335bb6 100644 --- a/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx +++ b/src/plugins/userVoiceShow/components/VoiceChannelSection.tsx @@ -18,12 +18,11 @@ import "./VoiceChannelSection.css"; -import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { findByPropsLazy } from "@webpack"; import { Button, Forms, PermissionStore, Toasts } from "@webpack/common"; import { Channel } from "discord-types/general"; const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel"); -const UserPopoutSection = findByCodeLazy(".lastSection", "children:"); const CONNECT = 1n << 20n; @@ -34,7 +33,8 @@ interface VoiceChannelFieldProps { } export const VoiceChannelSection = ({ channel, label, showHeader }: VoiceChannelFieldProps) => ( - + // @TODO The div is supposed to be a UserPopoutSection +
{showHeader && In a voice channel} - +
); diff --git a/src/plugins/userVoiceShow/index.tsx b/src/plugins/userVoiceShow/index.tsx index 53044a558..cad539b46 100644 --- a/src/plugins/userVoiceShow/index.tsx +++ b/src/plugins/userVoiceShow/index.tsx @@ -84,7 +84,7 @@ export default definePlugin({ ); }, - patchPopout: ({ user }: UserProps) => { + patchProfilePopout: ({ user }: UserProps) => { const isSelfUser = user.id === UserStore.getCurrentUser().id; return (
@@ -94,21 +94,7 @@ export default definePlugin({ }, patches: [ - // above message box - { - find: ".popularApplicationCommandIds,", - replacement: { - match: /(?<=,)(?=!\i&&!\i&&.{0,50}setNote:)/, - replace: "$self.patchPopout(arguments[0]),", - } - }, - // below username - { - find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Lazy-loaded - replacement: { - match: /\.body.+?displayProfile:\i}\),/, - replace: "$&$self.patchModal(arguments[0]),", - } - } + // @TODO Maybe patch UserVoiceShow in simplified profile popout + // @TODO Patch new profile modal ], }); diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 927a974f0..38d775540 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -192,14 +192,6 @@ export default definePlugin({ }, all: true }, - // Old Profiles Modal pfp - { - find: ".MODAL,hasProfileEffect", - replacement: { - match: /\{src:(\i)(?=,avatarDecoration)/, - replace: "{src:$1,onClick:()=>$self.openImage($1)" - } - }, // Banners ...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({ find, @@ -211,14 +203,6 @@ export default definePlugin({ 'onClick:ev=>$1&&ev.target.style.backgroundImage&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,' } })), - // Old User DMs "User Profile" popup in the right - { - find: ".avatarPositionPanel", - replacement: { - match: /(avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/, - replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}" - } - }, // Group DMs top small & large icon { find: /\.recipients\.length>=2(?!