From f43baddc550dfd30c1a6b44f7e42544b03084a5a Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Tue, 28 Jan 2025 01:57:16 +0000 Subject: [PATCH 1/3] NoBlockedMessages: Add ignored messages (#3126) --- src/plugins/noBlockedMessages/index.ts | 59 +++++++++++++++++--------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 48ca63d1..95b53c6b 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/Settings"; +import { definePluginSettings, migratePluginSetting } from "@api/Settings"; import { Devs } from "@utils/constants"; import { runtimeHashMessageKey } from "@utils/intlHash"; import { Logger } from "@utils/Logger"; @@ -32,10 +32,29 @@ interface MessageDeleteProps { collapsedReason: () => any; } +// Remove this migration once enough time has passed +migratePluginSetting("NoBlockedMessages", "ignoreBlockedMessages", "ignoreMessages"); +const settings = definePluginSettings({ + ignoreMessages: { + description: "Completely ignores incoming messages from blocked and ignored (if enabled) users", + type: OptionType.BOOLEAN, + default: false, + restartNeeded: true + }, + applyToIgnoredUsers: { + description: "Additionally apply to 'ignored' users", + type: OptionType.BOOLEAN, + default: true, + restartNeeded: false + } +}); + export default definePlugin({ name: "NoBlockedMessages", - description: "Hides all blocked messages from chat completely.", - authors: [Devs.rushii, Devs.Samu], + description: "Hides all blocked/ignored messages from chat completely", + authors: [Devs.rushii, Devs.Samu, Devs.jamesbt365], + settings, + patches: [ { find: "#{intl::BLOCKED_MESSAGES_HIDE}", @@ -51,38 +70,40 @@ export default definePlugin({ '"ReadStateStore"' ].map(find => ({ find, - predicate: () => Settings.plugins.NoBlockedMessages.ignoreBlockedMessages === true, + predicate: () => settings.store.ignoreMessages, replacement: [ { match: /(?<=function (\i)\((\i)\){)(?=.*MESSAGE_CREATE:\1)/, - replace: (_, _funcName, props) => `if($self.isBlocked(${props}.message))return;` + replace: (_, _funcName, props) => `if($self.shouldIgnoreMessage(${props}.message))return;` } ] })) ], - options: { - ignoreBlockedMessages: { - description: "Completely ignores (recent) incoming messages from blocked users (locally).", - type: OptionType.BOOLEAN, - default: false, - restartNeeded: true, - }, - }, - isBlocked(message: Message) { + shouldIgnoreMessage(message: Message) { try { - return RelationshipStore.isBlocked(message.author.id); + if (RelationshipStore.isBlocked(message.author.id)) { + return true; + } + return settings.store.applyToIgnoredUsers && RelationshipStore.isIgnored(message.author.id); } catch (e) { - new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e); + new Logger("NoBlockedMessages").error("Failed to check if user is blocked or ignored:", e); + return false; } }, - shouldHide(props: MessageDeleteProps) { + shouldHide(props: MessageDeleteProps): boolean { try { - return props.collapsedReason() === i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")](); + const collapsedReason = props.collapsedReason(); + const blockedReason = i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")](); + const ignoredReason = settings.store.applyToIgnoredUsers + ? i18n.t[runtimeHashMessageKey("IGNORED_MESSAGE_COUNT")]() + : null; + + return collapsedReason === blockedReason || collapsedReason === ignoredReason; } catch (e) { console.error(e); + return false; } - return false; } }); From cdc756193e93914d3f644f52ecc4d65dbd02d5a9 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 28 Jan 2025 01:13:36 -0300 Subject: [PATCH 2/3] Settings API: Fix erroring if plugin settings don't exist --- src/api/Settings.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/Settings.ts b/src/api/Settings.ts index 8c05d9bb..262722b1 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -224,8 +224,8 @@ export function migratePluginSetting(pluginName: string, oldSetting: string, new const { plugins } = SettingsStore.plain; if ( - plugins[pluginName][newSetting] != null || - plugins[pluginName][oldSetting] == null + plugins?.[pluginName]?.[oldSetting] == null || + plugins[pluginName][newSetting] != null ) return; plugins[pluginName][newSetting] = plugins[pluginName][oldSetting]; From 33d4f13a242fb4b5124010546773a7bda3d9d962 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 29 Jan 2025 01:04:36 -0300 Subject: [PATCH 3/3] Fix everything broken by recent Discord update (#3177) Co-authored-by: sadan <117494111+sadan4@users.noreply.github.com> Co-authored-by: Vendicated --- src/api/ChatButtons.tsx | 4 +- src/api/ContextMenu.ts | 8 +- src/api/Settings.ts | 12 +- src/debug/runReporter.ts | 15 +- src/plugins/_api/badges/index.tsx | 18 +-- src/plugins/_api/chatButtons.ts | 16 ++- src/plugins/_api/contextMenu.ts | 20 ++- src/plugins/_api/menuItemDemangler.ts | 68 +++++++++ src/plugins/_core/settings.tsx | 2 +- src/plugins/betterFolders/index.tsx | 4 +- src/plugins/betterSessions/index.tsx | 4 +- src/plugins/betterSettings/index.tsx | 4 +- src/plugins/consoleJanitor/index.ts | 4 +- src/plugins/consoleShortcuts/index.ts | 37 ++++- src/plugins/ctrlEnterSend/index.ts | 6 +- src/plugins/fakeNitro/index.tsx | 8 +- src/plugins/fullSearchContext/index.tsx | 4 +- src/plugins/gameActivityToggle/index.tsx | 2 +- src/plugins/iLoveSpam/index.ts | 2 +- src/plugins/ignoreActivities/index.tsx | 2 +- src/plugins/implicitRelationships/index.ts | 2 +- src/plugins/mentionAvatars/index.tsx | 2 +- src/plugins/messageLatency/index.tsx | 4 +- src/plugins/messageLogger/index.tsx | 2 +- src/plugins/openInApp/index.ts | 4 +- src/plugins/permissionFreeWill/index.ts | 4 +- .../pinDms/components/CreateCategoryModal.tsx | 4 +- src/plugins/platformIndicators/index.tsx | 8 +- src/plugins/showHiddenChannels/index.tsx | 22 +-- src/plugins/showTimeoutDuration/index.tsx | 4 +- src/plugins/typingIndicator/index.tsx | 4 +- src/plugins/userVoiceShow/components.tsx | 2 +- src/plugins/vencordToolbox/index.tsx | 4 +- src/plugins/viewIcons/index.tsx | 8 +- src/utils/modal.tsx | 81 ++++++----- src/webpack/common/components.ts | 130 +++++++++--------- src/webpack/common/menu.ts | 20 ++- src/webpack/common/types/components.d.ts | 3 - src/webpack/common/types/iconNames.d.ts | 14 -- src/webpack/patchWebpack.ts | 40 ++++-- src/webpack/webpack.ts | 31 +++-- 41 files changed, 389 insertions(+), 244 deletions(-) create mode 100644 src/plugins/_api/menuItemDemangler.ts delete mode 100644 src/webpack/common/types/iconNames.d.ts diff --git a/src/api/ChatButtons.tsx b/src/api/ChatButtons.tsx index c24e3886..6f4285ff 100644 --- a/src/api/ChatButtons.tsx +++ b/src/api/ChatButtons.tsx @@ -9,7 +9,7 @@ import "./ChatButton.css"; import ErrorBoundary from "@components/ErrorBoundary"; import { Logger } from "@utils/Logger"; import { waitFor } from "@webpack"; -import { Button, ButtonLooks, ButtonWrapperClasses, Tooltip } from "@webpack/common"; +import { Button, ButtonWrapperClasses, Tooltip } from "@webpack/common"; import { Channel } from "discord-types/general"; import { HTMLProps, JSX, MouseEventHandler, ReactNode } from "react"; @@ -110,7 +110,7 @@ export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => {