Skip to content

Commit 02092a9

Browse files
committed
BetterNotes: fix crashing
1 parent 9f79cc0 commit 02092a9

3 files changed

Lines changed: 43 additions & 30 deletions

File tree

src/components/VencordSettings/ThemesTab.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
import { useSettings } from "@api/Settings";
19+
import { Settings, useSettings } from "@api/Settings";
2020
import { classNameFactory } from "@api/Styles";
2121
import { Flex } from "@components/Flex";
2222
import { DeleteIcon, FolderIcon, PaintbrushIcon, PencilIcon, PlusIcon, RestartIcon } from "@components/Icons";
@@ -32,6 +32,8 @@ import { findByPropsLazy, findLazy } from "@webpack";
3232
import { Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
3333
import type { ComponentType, Ref, SyntheticEvent } from "react";
3434

35+
import Plugins from "~plugins";
36+
3537
import { AddonCard } from "./AddonCard";
3638
import { QuickAction, QuickActionCard } from "./quickActions";
3739
import { SettingsTab, wrapTab } from "./shared";
@@ -250,10 +252,10 @@ function ThemesTab() {
250252
Icon={PaintbrushIcon}
251253
/>
252254

253-
{Vencord.Settings.plugins.ClientTheme.enabled && (
255+
{Settings.plugins.ClientTheme.enabled && (
254256
<QuickAction
255257
text="Edit ClientTheme"
256-
action={() => openPluginModal(Vencord.Plugins.plugins.ClientTheme)}
258+
action={() => openPluginModal(Plugins.ClientTheme)}
257259
Icon={PencilIcon}
258260
/>
259261
)}

src/plugins/banger/index.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,34 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19+
import { definePluginSettings } from "@api/Settings";
1920
import { Devs } from "@utils/constants";
2021
import definePlugin, { OptionType } from "@utils/types";
2122

23+
const settings = definePluginSettings({
24+
source: {
25+
description: "Source to replace ban GIF with (Video or Gif)",
26+
type: OptionType.STRING,
27+
default: "https://i.imgur.com/wp5q52C.mp4",
28+
restartNeeded: true,
29+
}
30+
});
31+
2232
export default definePlugin({
2333
name: "BANger",
2434
description: "Replaces the GIF in the ban dialogue with a custom one.",
2535
authors: [Devs.Xinto, Devs.Glitch],
36+
settings,
2637
patches: [
2738
{
2839
find: "BAN_CONFIRM_TITLE.",
2940
replacement: {
3041
match: /src:\i\("?\d+"?\)/g,
31-
replace: "src: Vencord.Settings.plugins.BANger.source"
42+
replace: "src:$self.source"
3243
}
3344
}
3445
],
35-
options: {
36-
source: {
37-
description: "Source to replace ban GIF with (Video or Gif)",
38-
type: OptionType.STRING,
39-
default: "https://i.imgur.com/wp5q52C.mp4",
40-
restartNeeded: true,
41-
}
46+
get source() {
47+
return settings.store.source;
4248
}
4349
});

src/plugins/betterNotes/index.tsx

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
import { Settings } from "@api/Settings";
19+
import { definePluginSettings, Settings } from "@api/Settings";
2020
import ErrorBoundary from "@components/ErrorBoundary";
2121
import { Devs } from "@utils/constants";
2222
import { canonicalizeMatch } from "@utils/patches";
@@ -25,18 +25,34 @@ import { findByPropsLazy } from "@webpack";
2525

2626
const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection");
2727

28+
const settings = definePluginSettings({
29+
hide: {
30+
type: OptionType.BOOLEAN,
31+
description: "Hide notes",
32+
default: false,
33+
restartNeeded: true
34+
},
35+
noSpellCheck: {
36+
type: OptionType.BOOLEAN,
37+
description: "Disable spellcheck in notes",
38+
disabled: () => Settings.plugins.BetterNotesBox.hide,
39+
default: false
40+
}
41+
});
42+
2843
export default definePlugin({
2944
name: "BetterNotesBox",
3045
description: "Hide notes or disable spellcheck (Configure in settings!!)",
3146
authors: [Devs.Ven],
47+
settings,
3248

3349
patches: [
3450
{
3551
find: "hideNote:",
3652
all: true,
3753
// Some modules match the find but the replacement is returned untouched
3854
noWarn: true,
39-
predicate: () => Vencord.Settings.plugins.BetterNotesBox.hide,
55+
predicate: () => settings.store.hide,
4056
replacement: {
4157
match: /hideNote:.+?(?=([,}].*?\)))/g,
4258
replace: (m, rest) => {
@@ -54,7 +70,7 @@ export default definePlugin({
5470
find: "Messages.NOTE_PLACEHOLDER",
5571
replacement: {
5672
match: /\.NOTE_PLACEHOLDER,/,
57-
replace: "$&spellCheck:!Vencord.Settings.plugins.BetterNotesBox.noSpellCheck,"
73+
replace: "$&spellCheck:!$self.noSpellCheck,"
5874
}
5975
},
6076
{
@@ -66,25 +82,14 @@ export default definePlugin({
6682
}
6783
],
6884

69-
options: {
70-
hide: {
71-
type: OptionType.BOOLEAN,
72-
description: "Hide notes",
73-
default: false,
74-
restartNeeded: true
75-
},
76-
noSpellCheck: {
77-
type: OptionType.BOOLEAN,
78-
description: "Disable spellcheck in notes",
79-
disabled: () => Settings.plugins.BetterNotesBox.hide,
80-
default: false
81-
}
82-
},
83-
8485
patchPadding: ErrorBoundary.wrap(({ lastSection }) => {
8586
if (!lastSection) return null;
8687
return (
8788
<div className={UserPopoutSectionCssClasses.lastSection} ></div>
8889
);
89-
})
90+
}),
91+
92+
get noSpellCheck() {
93+
return settings.store.noSpellCheck;
94+
}
9095
});

0 commit comments

Comments
 (0)