diff --git a/src/plugins/keywordNotify/index.tsx b/src/plugins/keywordNotify/index.tsx index 612e49c89..f9c556078 100644 --- a/src/plugins/keywordNotify/index.tsx +++ b/src/plugins/keywordNotify/index.tsx @@ -6,40 +6,42 @@ import "./style.css"; +import definePlugin, { OptionType } from "@utils/types"; +import { Button, ChannelStore, Forms, SearchableSelect,SelectedChannelStore, TabBar, TextInput, UserStore, UserUtils, useState } from "@webpack/common"; +import { classNameFactory } from "@api/Styles"; import { DataStore } from "@api/index"; import { definePluginSettings } from "@api/Settings"; -import { Flex } from "@components/Flex"; import { DeleteIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; -import { Margins } from "@utils/margins"; -import { useForceUpdater } from "@utils/react"; -import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy } from "@webpack"; -import { Button, ChannelStore, Forms, SearchableSelect,SelectedChannelStore, TabBar, TextInput, UserStore, UserUtils, useState } from "@webpack/common"; +import { Flex } from "@components/Flex"; +import { Margins } from "@utils/margins"; import { Message, User } from "discord-types/general/index.js"; +import { useForceUpdater } from "@utils/react"; let keywordEntries: Array<{ regex: string, listIds: Array, listType: ListType }> = []; let currentUser: User; let keywordLog: Array = []; -const MenuHeader = findByCodeLazy(".useInDesktopNotificationCenterExperiment)()?"); -const Popout = findByCodeLazy("let{analyticsName:"); +const MenuHeader = findByCodeLazy(".sv)()?(0,"); +const Popout = findByCodeLazy(".loadingMore&&null=="); const recentMentionsPopoutClass = findByPropsLazy("recentMentionsPopout"); +const createMessageRecord = findByCodeLazy("THREAD_CREATED?[]:(0,"); const KEYWORD_ENTRIES_KEY = "KeywordNotify_keywordEntries"; const KEYWORD_LOG_KEY = "KeywordNotify_log"; -const { createMessageRecord } = findByPropsLazy("createMessageRecord", "updateMessageRecord"); +const cl = classNameFactory("vc-keywordnotify-"); -async function addKeywordEntry(updater: () => void) { +async function addKeywordEntry(forceUpdate: () => void) { keywordEntries.push({ regex: "", listIds: [], listType: ListType.BlackList }); await DataStore.set(KEYWORD_ENTRIES_KEY, keywordEntries); - updater(); + forceUpdate(); } -async function removeKeywordEntry(idx: number, updater: () => void) { +async function removeKeywordEntry(idx: number, forceUpdate: () => void) { keywordEntries.splice(idx, 1); await DataStore.set(KEYWORD_ENTRIES_KEY, keywordEntries); - updater(); + forceUpdate(); } function safeMatchesRegex(s: string, r: string) { @@ -50,7 +52,6 @@ function safeMatchesRegex(s: string, r: string) { } } - enum ListType { BlackList = "BlackList", Whitelist = "Whitelist" @@ -90,7 +91,7 @@ function Collapsible({ title, children }) { onClick={() => setIsOpen(!isOpen)} look={Button.Looks.BLANK} size={Button.Sizes.ICON} - className="keywordnotify-collapsible"> + className={cl("collapsible")}>
{isOpen ? "▼" : "▶"}
{title} @@ -130,7 +131,7 @@ function ListedIds({ listIds, setListIds }) { }} look={Button.Looks.BLANK} size={Button.Sizes.ICON} - className="keywordnotify-delete"> + className={cl("delete")}> @@ -200,18 +201,18 @@ function KeywordEntries() { onClick={() => removeKeywordEntry(i, update)} look={Button.Looks.BLANK} size={Button.Sizes.ICON} - className="keywordnotify-delete"> + className={cl("delete")}> - + Whitelist/Blacklist
setListIds(i, e)}/>
-
+