From 560fb982e6f8b3960dd540f50ff5aab590491cbc Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 3 Jul 2024 21:38:21 +0200 Subject: [PATCH] BetterNotes: fix crashing --- src/components/VencordSettings/ThemesTab.tsx | 8 ++-- src/plugins/banger/index.ts | 22 ++++++---- src/plugins/betterNotes/index.tsx | 43 +++++++++++--------- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx index 016371bed..aa8761d76 100644 --- a/src/components/VencordSettings/ThemesTab.tsx +++ b/src/components/VencordSettings/ThemesTab.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { useSettings } from "@api/Settings"; +import { Settings, useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import { Flex } from "@components/Flex"; import { DeleteIcon, FolderIcon, PaintbrushIcon, PencilIcon, PlusIcon, RestartIcon } from "@components/Icons"; @@ -32,6 +32,8 @@ import { findByPropsLazy, findLazy } from "@webpack"; import { Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common"; import type { ComponentType, Ref, SyntheticEvent } from "react"; +import Plugins from "~plugins"; + import { AddonCard } from "./AddonCard"; import { QuickAction, QuickActionCard } from "./quickActions"; import { SettingsTab, wrapTab } from "./shared"; @@ -250,10 +252,10 @@ function ThemesTab() { Icon={PaintbrushIcon} /> - {Vencord.Settings.plugins.ClientTheme.enabled && ( + {Settings.plugins.ClientTheme.enabled && ( openPluginModal(Vencord.Plugins.plugins.ClientTheme)} + action={() => openPluginModal(Plugins.ClientTheme)} Icon={PencilIcon} /> )} diff --git a/src/plugins/banger/index.ts b/src/plugins/banger/index.ts index 7e0d2df73..eca80f9ee 100644 --- a/src/plugins/banger/index.ts +++ b/src/plugins/banger/index.ts @@ -16,28 +16,34 @@ * along with this program. If not, see . */ +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; +const settings = definePluginSettings({ + source: { + description: "Source to replace ban GIF with (Video or Gif)", + type: OptionType.STRING, + default: "https://i.imgur.com/wp5q52C.mp4", + restartNeeded: true, + } +}); + export default definePlugin({ name: "BANger", description: "Replaces the GIF in the ban dialogue with a custom one.", authors: [Devs.Xinto, Devs.Glitch], + settings, patches: [ { find: "BAN_CONFIRM_TITLE.", replacement: { match: /src:\i\("?\d+"?\)/g, - replace: "src: Vencord.Settings.plugins.BANger.source" + replace: "src:$self.source" } } ], - options: { - source: { - description: "Source to replace ban GIF with (Video or Gif)", - type: OptionType.STRING, - default: "https://i.imgur.com/wp5q52C.mp4", - restartNeeded: true, - } + get source() { + return settings.store.source; } }); diff --git a/src/plugins/betterNotes/index.tsx b/src/plugins/betterNotes/index.tsx index cacdba5fd..b97076bf4 100644 --- a/src/plugins/betterNotes/index.tsx +++ b/src/plugins/betterNotes/index.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/Settings"; +import { definePluginSettings, Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { canonicalizeMatch } from "@utils/patches"; @@ -25,10 +25,26 @@ import { findByPropsLazy } from "@webpack"; const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection"); +const settings = definePluginSettings({ + hide: { + type: OptionType.BOOLEAN, + description: "Hide notes", + default: false, + restartNeeded: true + }, + noSpellCheck: { + type: OptionType.BOOLEAN, + description: "Disable spellcheck in notes", + disabled: () => Settings.plugins.BetterNotesBox.hide, + default: false + } +}); + export default definePlugin({ name: "BetterNotesBox", description: "Hide notes or disable spellcheck (Configure in settings!!)", authors: [Devs.Ven], + settings, patches: [ { @@ -36,7 +52,7 @@ export default definePlugin({ all: true, // Some modules match the find but the replacement is returned untouched noWarn: true, - predicate: () => Vencord.Settings.plugins.BetterNotesBox.hide, + predicate: () => settings.store.hide, replacement: { match: /hideNote:.+?(?=([,}].*?\)))/g, replace: (m, rest) => { @@ -54,7 +70,7 @@ export default definePlugin({ find: "Messages.NOTE_PLACEHOLDER", replacement: { match: /\.NOTE_PLACEHOLDER,/, - replace: "$&spellCheck:!Vencord.Settings.plugins.BetterNotesBox.noSpellCheck," + replace: "$&spellCheck:!$self.noSpellCheck," } }, { @@ -66,25 +82,14 @@ export default definePlugin({ } ], - options: { - hide: { - type: OptionType.BOOLEAN, - description: "Hide notes", - default: false, - restartNeeded: true - }, - noSpellCheck: { - type: OptionType.BOOLEAN, - description: "Disable spellcheck in notes", - disabled: () => Settings.plugins.BetterNotesBox.hide, - default: false - } - }, - patchPadding: ErrorBoundary.wrap(({ lastSection }) => { if (!lastSection) return null; return (
); - }) + }), + + get noSpellCheck() { + return settings.store.noSpellCheck; + } });