Update styles of restart tooltip + debug edit raw function

This commit is contained in:
Sqaaakoi 2024-08-31 01:58:23 +12:00
parent d567b3cee9
commit 1820dc001a
No known key found for this signature in database
4 changed files with 29 additions and 39 deletions

11
NewPluginsModal.css Normal file
View file

@ -0,0 +1,11 @@
.vc-newPluginsManager-restart-tooltip {
max-width: 280px;
}
.vc-newPluginsManager-restart-list {
padding-left: 1.25em;
}
.vc-newPluginsManager-restart-list li {
list-style: disc;
}

View file

@ -10,7 +10,7 @@ import { PluginCard } from "@components/PluginSettings";
import { ChangeList } from "@utils/ChangeList"; import { ChangeList } from "@utils/ChangeList";
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { useForceUpdater } from "@utils/react"; import { useForceUpdater } from "@utils/react";
import { Button, Flex, Forms, Parser, React, Text, Tooltip, useMemo } from "@webpack/common"; import { Button, Flex, Forms, React, Text, Tooltip, useMemo } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
import Plugins from "~plugins"; import Plugins from "~plugins";
@ -19,6 +19,10 @@ import { getNewPlugins, getNewSettings, KnownPluginSettingsMap, writeKnownSettin
const cl = classNameFactory("vc-plugins-"); const cl = classNameFactory("vc-plugins-");
import "./NewPluginsModal.css";
import { Margins } from "@utils/index";
let hasSeen = false; let hasSeen = false;
// Most of this was stolen from PluginSettings directly. // Most of this was stolen from PluginSettings directly.
@ -133,14 +137,13 @@ function ContinueButton(props: { callback: (update: () => void) => void; changes
const update = useForceUpdater(); const update = useForceUpdater();
props.callback(update); props.callback(update);
return <Tooltip return <Tooltip
tooltipClassName="vc-newPluginsManager-restart-tooltip"
text={<> text={<>
The following plugins require a restart: The following plugins require a restart:
<div>{props.changes.map((s, i) => ( <div className={Margins.bottom8} />
<> <ul className="vc-newPluginsManager-restart-list">
{i > 0 && ", "} {props.changes.map(p => <li>{p}</li>)}
{Parser.parse("`" + s + "`")} </ul>
</>
))}</div>
</>} </>}
shouldShow={props.changes.hasChanges} shouldShow={props.changes.hasChanges}
> >

View file

@ -1,32 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { DataStore } from "@api/index";
import plugins from "~plugins";
export const KNOWN_PLUGINS_DATA_KEY = "NewPluginsManager_KnownPlugins";
export async function getKnownPlugins(): Promise<Set<string>> {
let knownPlugins = await DataStore.get(KNOWN_PLUGINS_DATA_KEY) as string[];
if (knownPlugins === undefined) {
knownPlugins = Object.keys(plugins);
DataStore.set(KNOWN_PLUGINS_DATA_KEY, knownPlugins);
}
return new Set(knownPlugins);
}
export async function getNewPlugins(): Promise<Set<string>> {
const currentPlugins = Object.keys(plugins);
const knownPlugins = await getKnownPlugins();
return new Set(currentPlugins.filter(p => !knownPlugins.has(p)));
}
export async function writeKnownPlugins(): Promise<void> {
const currentPlugins = Object.keys(plugins);
const knownPlugins = await getKnownPlugins();
DataStore.set(KNOWN_PLUGINS_DATA_KEY, [...new Set([...currentPlugins, ...knownPlugins])]);
}

View file

@ -83,3 +83,11 @@ export async function debugWipeSomeData() {
}); });
await DataStore.set(KNOWN_SETTINGS_DATA_KEY, settings); await DataStore.set(KNOWN_SETTINGS_DATA_KEY, settings);
} }
export async function editRawData(patcher: (data: KnownPluginSettingsMap) => (Promise<KnownPluginSettingsMap> | KnownPluginSettingsMap)) {
if (!patcher) return;
const map = await DataStore.get(KNOWN_SETTINGS_DATA_KEY) as KnownPluginSettingsMap;
const newMap = new Map(map);
await patcher(newMap);
await DataStore.set(KNOWN_SETTINGS_DATA_KEY, newMap ?? map);
}