From 84c53b4a27404059446f3748af32cb4da8d2bac0 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 3 May 2024 04:52:07 -0300 Subject: [PATCH] MoreUserTags: Remove old workaround; MessageClickActions: Move finds outside of start --- src/plugins/messageClickActions/index.ts | 7 +++---- src/plugins/moreUserTags/index.tsx | 12 +++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/plugins/messageClickActions/index.ts b/src/plugins/messageClickActions/index.ts index 052c33f61..3d4bb21bb 100644 --- a/src/plugins/messageClickActions/index.ts +++ b/src/plugins/messageClickActions/index.ts @@ -23,11 +23,13 @@ import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore } from "@webpack/common"; +const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage"); +const EditStore = findByPropsLazy("isEditing", "isEditingAny"); + let isDeletePressed = false; const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = false); - const settings = definePluginSettings({ enableDeleteOnClick: { type: OptionType.BOOLEAN, @@ -60,9 +62,6 @@ export default definePlugin({ settings, start() { - const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage"); - const EditStore = findByPropsLazy("isEditing", "isEditingAny"); - document.addEventListener("keydown", keydown); document.addEventListener("keyup", keyup); diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 4ac542216..df47e5456 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -198,8 +198,7 @@ export default definePlugin({ replacement: [ // make the tag show the right text { - // FIXME: Remove the BOT_TAG_BOT variant when the change arrives in stable - match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=.{0,40}(\i\.\i\.Messages)\.(?:APP_TAG|BOT_TAG_BOT)/, + match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=.{0,40}(\i\.\i\.Messages)\.APP_TAG/, replace: (_, origSwitch, variant, tags, displayedText, strings) => `${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}], ${strings})}` }, @@ -322,20 +321,19 @@ export default definePlugin({ isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]), - // FIXME: Remove the BOT_TAG_BOT variants from strings when the change arrives in stable getTagText(passedTagName: string, strings: Record) { - if (!passedTagName) return strings.APP_TAG ?? strings.BOT_TAG_BOT; + if (!passedTagName) return strings.APP_TAG; const [tagName, variant] = passedTagName.split("-"); const tag = tags.find(({ name }) => tagName === name); - if (!tag) return strings.APP_TAG ?? strings.BOT_TAG_BOT; - if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.APP_TAG ?? strings.BOT_TAG_BOT; + if (!tag) return strings.APP_TAG; + if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.APP_TAG; const tagText = settings.store.tagSettings?.[tag.name]?.text || tag.displayName; switch (variant) { case "OP": return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER} • ${tagText}`; case "BOT": - return `${strings.APP_TAG ?? strings.BOT_TAG_BOT} • ${tagText}`; + return `${strings.APP_TAG} • ${tagText}`; default: return tagText; }