From 9a02e43cfbad6a73c357acb56431e15845e0bf05 Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Sat, 12 Oct 2024 07:14:49 +1300 Subject: [PATCH] Add Don't show this again checkbox, Fix dismiss button, detect registered settings instead of saved settings --- NewPluginsModal.css | 4 ++++ NewPluginsModal.tsx | 34 ++++++++++++++++++++++++---------- knownSettings.ts | 5 ++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/NewPluginsModal.css b/NewPluginsModal.css index c941823..3e825dd 100644 --- a/NewPluginsModal.css +++ b/NewPluginsModal.css @@ -9,3 +9,7 @@ .vc-newPluginsManager-restart-list li { list-style: disc; } + +.vc-newPluginsManager-close > div { + display: flex; +} diff --git a/NewPluginsModal.tsx b/NewPluginsModal.tsx index e9fbf64..f3c96b2 100644 --- a/NewPluginsModal.tsx +++ b/NewPluginsModal.tsx @@ -4,12 +4,16 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { useSettings } from "@api/Settings"; +import "./NewPluginsModal.css"; + +import { Settings, useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import { PluginCard } from "@components/PluginSettings"; import { ChangeList } from "@utils/ChangeList"; +import { classes, Margins } from "@utils/index"; import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { useForceUpdater } from "@utils/react"; +import { findByPropsLazy } from "@webpack"; import { Button, Flex, Forms, React, Text, Tooltip, useMemo } from "@webpack/common"; import { JSX } from "react"; @@ -19,9 +23,7 @@ import { getNewPlugins, getNewSettings, KnownPluginSettingsMap, writeKnownSettin const cl = classNameFactory("vc-plugins-"); -import "./NewPluginsModal.css"; - -import { Margins } from "@utils/index"; +const { Checkbox } = findByPropsLazy("FormItem", "Button"); let hasSeen = false; @@ -105,14 +107,15 @@ export function NewPluginsModal({ modalProps, newPlugins, newSettings }: { modal return - New Plugins and Settings ({[...plugins, ...requiredPlugins].length}) + New Plugins and Settings ({[...plugins, ...requiredPlugins].length}) {tooltipProps => - +
+ +
}
@@ -129,6 +132,17 @@ export function NewPluginsModal({ modalProps, newPlugins, newSettings }: { modal callback={(v: () => void) => updateContinueButton = v} /> + + { + Settings.plugins.NewPluginsManager.enabled = !settings?.plugins?.NewPluginsManager?.enabled; + }} + > + Don't show this again + +
; } diff --git a/knownSettings.ts b/knownSettings.ts index c4d1a90..d44da26 100644 --- a/knownSettings.ts +++ b/knownSettings.ts @@ -5,7 +5,6 @@ */ import { DataStore } from "@api/index"; -import { Settings } from "@api/Settings"; import plugins from "~plugins"; @@ -15,7 +14,7 @@ export const KNOWN_PLUGINS_LEGACY_DATA_KEY = "NewPluginsManager_KnownPlugins"; export const KNOWN_SETTINGS_DATA_KEY = "NewPluginsManager_KnownSettings"; function getSettingsSetForPlugin(plugin: string): Set { - const settings = Settings.plugins[plugin] || {}; + const settings = plugins[plugin]?.settings?.def || {}; return new Set(Object.keys(settings).filter(setting => setting !== "enabled")); } @@ -84,7 +83,7 @@ export async function debugWipeSomeData() { await DataStore.set(KNOWN_SETTINGS_DATA_KEY, settings); } -export async function editRawData(patcher: (data: KnownPluginSettingsMap) => (Promise | KnownPluginSettingsMap)) { +export async function editRawData(patcher: (data: KnownPluginSettingsMap) => (Promise | any)) { if (!patcher) return; const map = await DataStore.get(KNOWN_SETTINGS_DATA_KEY) as KnownPluginSettingsMap; const newMap = new Map(map);