From e620e46ebee2f306fe518053fb6565ac953d9d41 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 17 Apr 2025 22:50:16 -0400 Subject: [PATCH] Remove Some Functionality From BetterBlockUsers Temp --- .../betterBlockedUsers/index.tsx | 51 +++++++------------ 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/src/equicordplugins/betterBlockedUsers/index.tsx b/src/equicordplugins/betterBlockedUsers/index.tsx index b3d64864..f1a5efb5 100644 --- a/src/equicordplugins/betterBlockedUsers/index.tsx +++ b/src/equicordplugins/betterBlockedUsers/index.tsx @@ -10,7 +10,7 @@ import { openUserProfile } from "@utils/discord"; import { openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack"; -import { Button, FluxDispatcher, React, RelationshipStore, Text, TextInput, UserStore } from "@webpack/common"; +import { Button, FluxDispatcher, React, RelationshipStore, showToast, Text, TextInput, UserStore } from "@webpack/common"; import { ButtonProps } from "@webpack/types"; import { User } from "discord-types/general"; @@ -27,12 +27,6 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, description: "Adds a 'View DMs' button to the users in the blocked/ignored list.", }, - hideBlockedWarning: { - default: false, - type: OptionType.BOOLEAN, - description: "Skip the warning about blocked/ignored users when opening any profile anywhere on discord outside of the blocklist.", - restartNeeded: true, - }, showUnblockConfirmation: { default: true, type: OptionType.BOOLEAN, @@ -49,6 +43,11 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, description: "Color the unblock button in the blocklist red instead of gray.", }, + allowShiftUnblock: { + default: true, + type: OptionType.BOOLEAN, + description: "Unblock a user without confirmation prompting when holding shift.", + } }); export default definePlugin({ @@ -84,6 +83,7 @@ export default definePlugin({ }, { find: "#{intl::OUTGOING_FRIEND_REQUEST}", + group: true, replacement: [ { match: /(?<=return \i)\|\|(\i)===.*?.FRIEND/, @@ -95,26 +95,6 @@ export default definePlugin({ } ], }, - { - find: ',["user"])', - replacement: { - match: /(?<=isIgnored:.*?,\[\i,\i]=\i.useState\()\i\|\|\i\|\|\i.*?]\);/, - replace: "false);" - }, - }, - - // If the users wishes to, they can disable the warning in all other places as well. - ...[ - "UserProfilePanelWrapper: currentUser cannot be undefined", - "UserProfilePopoutWrapper: currentUser cannot be undefined", - ].map(x => ({ - find: x, - replacement: { - match: /(?<=isIgnored:.*?,\[\i,\i]=\i.useState\()\i\|\|\i\|\|\i\)(?:;\i.useEffect.*?]\))?/, - replace: "false)", - }, - predicate: () => settings.store.hideBlockedWarning, - })), { find: ".BLOCKED:return", @@ -185,8 +165,6 @@ export default definePlugin({ if (settings.store.unblockButtonDanger) originalProps.color = Button.Colors.RED; - // TODO add extra unblock confirmation after the click + setting. - if (settings.store.showUnblockConfirmation || settings.store.showUnblockConfirmationEverywhere) { const originalOnClick = originalProps.onClick!; originalProps.onClick = e => { @@ -208,12 +186,19 @@ export default definePlugin({ }, openDMChannel(user: User) { - ChannelActions.openPrivateChannel(user.id); + try { + ChannelActions.openPrivateChannel(user.id); + } + catch (e) { + showToast("Failed to open DMs for user '" + user.username + "'! Check the console for more info"); + return console.error(e); + } + // only close the settings window if we actually opened a DM channel behind it. this.closeSettingsWindow(); - return null; }, + openConfirmationModal(event: MouseEvent, callback: () => any, user: User | string, isSettingsOrigin: boolean = false) { - if (event.shiftKey) return callback(); + if (event.shiftKey && settings.store.allowShiftUnblock) return callback(); if (typeof user === "string") { user = UserStore.getUser(user); @@ -222,7 +207,7 @@ export default definePlugin({ return openModal(m => {