mirror of
https://github.com/Sqaaakoi/vc-newPluginsManager.git
synced 2024-11-16 14:54:37 -05:00
Update styles of restart tooltip + debug edit raw function
This commit is contained in:
parent
d567b3cee9
commit
1820dc001a
4 changed files with 29 additions and 39 deletions
11
NewPluginsModal.css
Normal file
11
NewPluginsModal.css
Normal 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;
|
||||
}
|
|
@ -10,7 +10,7 @@ import { PluginCard } from "@components/PluginSettings";
|
|||
import { ChangeList } from "@utils/ChangeList";
|
||||
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
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 Plugins from "~plugins";
|
||||
|
@ -19,6 +19,10 @@ import { getNewPlugins, getNewSettings, KnownPluginSettingsMap, writeKnownSettin
|
|||
|
||||
const cl = classNameFactory("vc-plugins-");
|
||||
|
||||
import "./NewPluginsModal.css";
|
||||
|
||||
import { Margins } from "@utils/index";
|
||||
|
||||
let hasSeen = false;
|
||||
|
||||
// Most of this was stolen from PluginSettings directly.
|
||||
|
@ -133,14 +137,13 @@ function ContinueButton(props: { callback: (update: () => void) => void; changes
|
|||
const update = useForceUpdater();
|
||||
props.callback(update);
|
||||
return <Tooltip
|
||||
tooltipClassName="vc-newPluginsManager-restart-tooltip"
|
||||
text={<>
|
||||
The following plugins require a restart:
|
||||
<div>{props.changes.map((s, i) => (
|
||||
<>
|
||||
{i > 0 && ", "}
|
||||
{Parser.parse("`" + s + "`")}
|
||||
</>
|
||||
))}</div>
|
||||
<div className={Margins.bottom8} />
|
||||
<ul className="vc-newPluginsManager-restart-list">
|
||||
{props.changes.map(p => <li>{p}</li>)}
|
||||
</ul>
|
||||
</>}
|
||||
shouldShow={props.changes.hasChanges}
|
||||
>
|
||||
|
|
|
@ -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])]);
|
||||
}
|
|
@ -83,3 +83,11 @@ export async function debugWipeSomeData() {
|
|||
});
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue