From eae8947a09f78aba2b1de9f441945beb433145a9 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 3 Apr 2025 00:53:44 -0400 Subject: [PATCH] Add BetterBlockedContext to BetterBlockedUsers --- README.md | 2 +- .../betterBlockedUsers/index.tsx | 72 +++++++++++++------ .../betterBlockedUsers/styles.css | 3 - 3 files changed, 50 insertions(+), 27 deletions(-) delete mode 100644 src/equicordplugins/betterBlockedUsers/styles.css diff --git a/README.md b/README.md index 9968cacc..93c618af 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - BetterActivities by D3SOX, Arjix, AutumnVN - BetterAudioPlayer by Creations - BetterBanReasons by Inbestigator -- BetterBlockedUsers by TheArmagan +- BetterBlockedUsers by TheArmagan & Elvyra - BetterInvites by iamme - BetterPlusReacts by Joona - BetterQuickReact by Ven & Sqaaakoi diff --git a/src/equicordplugins/betterBlockedUsers/index.tsx b/src/equicordplugins/betterBlockedUsers/index.tsx index 61a1dd63..03d2d911 100644 --- a/src/equicordplugins/betterBlockedUsers/index.tsx +++ b/src/equicordplugins/betterBlockedUsers/index.tsx @@ -6,18 +6,30 @@ import "./styles.css"; -import { EquicordDevs } from "@utils/constants"; -import { getIntlMessage, openUserProfile } from "@utils/discord"; -import definePlugin from "@utils/types"; -import { Button, React, RelationshipStore, TextInput, UserStore } from "@webpack/common"; +import { definePluginSettings } from "@api/Settings"; +import { Devs, EquicordDevs } from "@utils/constants"; +import { openUserProfile } from "@utils/discord"; +import definePlugin, { OptionType } from "@utils/types"; +import { FluxDispatcher, React, RelationshipStore, TextInput, UserStore } from "@webpack/common"; +import { User } from "discord-types/general"; let lastSearch = ""; let updateFunc = (v: any) => { }; +const settings = definePluginSettings({ + hideBlockedWarning: { + default: true, + type: OptionType.BOOLEAN, + description: "Skip the warning about blocked/ignored users when opening the profile through the blocklist.", + restartNeeded: true, + }, +}); + export default definePlugin({ name: "BetterBlockedUsers", - description: "Allows you to search in blocked users list and makes names selectable in settings.", - authors: [EquicordDevs.TheArmagan], + description: "Allows you to search in blocked users list and makes names clickable in settings.", + authors: [EquicordDevs.TheArmagan, Devs.Elvyra], + settings, patches: [ { find: '"],{numberOfBlockedUsers:', @@ -27,8 +39,8 @@ export default definePlugin({ replace: ",$1.listType==='blocked'?$self.renderSearchInput():null" }, { - match: /(?<=userId:(\i).*?\}\)\]\}\),)(\(.*?\)\}\))/, - replace: "$self.renderUser($1,$2),", + match: /(?<=className:\i.userInfo,)(?=children:.{0,20}user:(\i))/, + replace: "style:{cursor:'pointer'},onClick:()=>$self.openUserProfile($1)," }, { match: /(?<=\}=(\i).{0,10}(\i).useState\(.{0,1}\);)/, @@ -39,7 +51,28 @@ export default definePlugin({ replace: "$1(searchResults.length?searchResults:$2)" }, ] - } + }, + { + find: "UserProfileModalHeaderActionButtons", + replacement: [ + { + match: /(?<=return \i)\|\|(\i)===.*?.FRIEND/, + replace: (_, type) => `?null:${type} === 1|| ${type} === 2`, + }, + { + match: /(?<=\i.bot.{0,50}children:.*?onClose:)(\i)/, + replace: "() => {$1();$self.closeSettingsWindow()}", + } + ], + }, + { + find: ',["user"])', + replacement: { + match: /(?<=isIgnored:.*?,\[\i,\i]=\i.useState\()\i\|\|\i\|\|\i.*?]\);/, + replace: "false);" + }, + predicate: () => settings.store.hideBlockedWarning, + }, ], renderSearchInput() { const [value, setValue] = React.useState(lastSearch); @@ -61,19 +94,6 @@ export default definePlugin({ }} value={value} >; }, - renderUser(userId: string, rest: any) { - return ( -
- - {rest} -
- ); - }, - getSearchResults() { - return !!lastSearch; - }, setUpdateFunc(e, setResults) { if (e.listType !== "blocked") return; updateFunc = setResults; @@ -86,5 +106,11 @@ export default definePlugin({ if (!user) return id === search; return id === search || user?.username?.toLowerCase()?.includes(search) || user?.globalName?.toLowerCase()?.includes(search); }) as string[]; - } + }, + closeSettingsWindow: () => { + FluxDispatcher.dispatch({ type: "LAYER_POP" }); + }, + openUserProfile: (user: User) => { + openUserProfile(user.id); + }, }); diff --git a/src/equicordplugins/betterBlockedUsers/styles.css b/src/equicordplugins/betterBlockedUsers/styles.css deleted file mode 100644 index 810c6772..00000000 --- a/src/equicordplugins/betterBlockedUsers/styles.css +++ /dev/null @@ -1,3 +0,0 @@ -[class*="usersList_"] [class*="text_"] { - user-select: text !important; -}