diff --git a/src/equicordplugins/baseDecoder/index.tsx b/src/equicordplugins/baseDecoder/index.tsx index 42df06286..dae20120c 100644 --- a/src/equicordplugins/baseDecoder/index.tsx +++ b/src/equicordplugins/baseDecoder/index.tsx @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover"; import { definePluginSettings } from "@api/Settings"; import { CodeBlock } from "@components/CodeBlock"; import ErrorBoundary from "@components/ErrorBoundary"; @@ -112,49 +111,42 @@ export default definePlugin({ authors: [EquicordDevs.ThePirateStoner], dependencies: ["MessagePopoverAPI"], settings, + renderMessagePopoverButton(msg) { + const handleClick = () => { + const base64Strings = findBase64Strings(msg.content); + const decodedContent = decodeBase64Strings(base64Strings); + if (settings.store.clickMethod === "Right") { + decodedContent.forEach(content => copyWithToast(content)); + } else { + openDecodedBase64Modal(decodedContent); + } + }; - start() { - addMessagePopoverButton("DecodeBase64", msg => { - const handleClick = () => { - const base64Strings = findBase64Strings(msg.content); - const decodedContent = decodeBase64Strings(base64Strings); - if (settings.store.clickMethod === "Right") { - decodedContent.forEach(content => copyWithToast(content)); - } else { - openDecodedBase64Modal(decodedContent); - } - }; + const handleContextMenu = e => { + const base64Strings = findBase64Strings(msg.content); + const decodedContent = decodeBase64Strings(base64Strings); + if (settings.store.clickMethod === "Left") { + e.preventDefault(); + e.stopPropagation(); + decodedContent.forEach(content => copyWithToast(content)); + } else { + e.preventDefault(); + e.stopPropagation(); + openDecodedBase64Modal(decodedContent); + } + }; - const handleContextMenu = e => { - const base64Strings = findBase64Strings(msg.content); - const decodedContent = decodeBase64Strings(base64Strings); - if (settings.store.clickMethod === "Left") { - e.preventDefault(); - e.stopPropagation(); - decodedContent.forEach(content => copyWithToast(content)); - } else { - e.preventDefault(); - e.stopPropagation(); - openDecodedBase64Modal(decodedContent); - } - }; + const label = settings.store.clickMethod === "Right" + ? "Copy Decoded (Left Click) / Decode Base64 (Right Click)" + : "Decode Base64 (Left Click) / Copy Decoded (Right Click)"; - const label = settings.store.clickMethod === "Right" - ? "Copy Decoded (Left Click) / Decode Base64 (Right Click)" - : "Decode Base64 (Left Click) / Copy Decoded (Right Click)"; - - return { - label, - icon: DecodeIcon, - message: msg, - channel: ChannelStore.getChannel(msg.channel_id), - onClick: handleClick, - onContextMenu: handleContextMenu - }; - }); - }, - - stop() { - removeMessagePopoverButton("DecodeBase64"); + return { + label, + icon: DecodeIcon, + message: msg, + channel: ChannelStore.getChannel(msg.channel_id), + onClick: handleClick, + onContextMenu: handleContextMenu + }; } });