From 6659f2c4134ad9f284a8eac1b38ea16252c86c27 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 24 Aug 2024 00:19:10 +0200 Subject: [PATCH 1/2] bump to v1.9.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 22b99f8bc..65d97f2e0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.9.7", + "version": "1.9.8", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 7ec842d4b0c94ee10d598e7daa320549554a8978 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:09:58 -0300 Subject: [PATCH 2/2] MoreUserTags: fix settings ui logic Co-authored-by: Vendicated --- src/api/Settings.ts | 4 ++++ src/plugins/moreUserTags/index.tsx | 29 +++++++---------------------- src/utils/types.ts | 2 ++ 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/api/Settings.ts b/src/api/Settings.ts index 88337a917..ac116f547 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -230,6 +230,10 @@ export function definePluginSettings< if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized"); return Settings.plugins[definedSettings.pluginName] as any; }, + get plain() { + if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized"); + return PlainSettings.plugins[definedSettings.pluginName] as any; + }, use: settings => useSettings( settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings[] ).plugins[definedSettings.pluginName] as any, diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 4802f04a1..0a87c57a9 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -22,7 +22,7 @@ import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findLazy } from "@webpack"; -import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common"; +import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip } from "@webpack/common"; import type { Permissions, RC } from "@webpack/types"; import type { Channel, Guild, Message, User } from "discord-types/general"; @@ -107,14 +107,8 @@ const defaultSettings = Object.fromEntries( tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }]) ) as TagSettings; -function SettingsComponent(props: { setValue(v: any): void; }) { - settings.store.tagSettings ??= defaultSettings; - - const [tagSettings, setTagSettings] = useState(settings.store.tagSettings as TagSettings); - const setValue = (v: TagSettings) => { - setTagSettings(v); - props.setValue(v); - }; +function SettingsComponent() { + const tagSettings = settings.store.tagSettings ??= defaultSettings; return ( @@ -137,19 +131,13 @@ function SettingsComponent(props: { setValue(v: any): void; }) { type="text" value={tagSettings[t.name]?.text ?? t.displayName} placeholder={`Text on tag (default: ${t.displayName})`} - onChange={v => { - tagSettings[t.name].text = v; - setValue(tagSettings); - }} + onChange={v => tagSettings[t.name].text = v} className={Margins.bottom16} /> { - tagSettings[t.name].showInChat = v; - setValue(tagSettings); - }} + onChange={v => tagSettings[t.name].showInChat = v} hideBorder > Show in messages @@ -157,10 +145,7 @@ function SettingsComponent(props: { setValue(v: any): void; }) { { - tagSettings[t.name].showInNotChat = v; - setValue(tagSettings); - }} + onChange={v => tagSettings[t.name].showInNotChat = v} hideBorder > Show in member list and profiles @@ -183,7 +168,7 @@ const settings = definePluginSettings({ tagSettings: { type: OptionType.COMPONENT, component: SettingsComponent, - description: "fill me", + description: "fill me" } }); diff --git a/src/utils/types.ts b/src/utils/types.ts index 8c24843f8..e5486e9a5 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -309,6 +309,8 @@ export interface DefinedSettings< > { /** Shorthand for `Vencord.Settings.plugins.PluginName`, but with typings */ store: SettingsStore & PrivateSettings; + /** Shorthand for `Vencord.PlainSettings.plugins.PluginName`, but with typings */ + plain: SettingsStore & PrivateSettings; /** * React hook for getting the settings for this plugin * @param filter optional filter to avoid rerenders for irrelevent settings