mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 07:25:10 +00:00
blep
This commit is contained in:
parent
9ccdaf4d5f
commit
b166668522
3 changed files with 10 additions and 11 deletions
|
@ -226,12 +226,12 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) {
|
|||
|
||||
export function migrateSettingsToArrays(pluginName: string, settings: string[], stringSeparator: string | ((input: string) => string[]) = ",") {
|
||||
const { plugins } = SettingsStore.plain;
|
||||
|
||||
if (plugins[pluginName] === undefined)
|
||||
return logger.error(`Plugin '${pluginName}' does not exist and cannot be migrated! Did you spell it correctly?`);
|
||||
for (const setting of settings) {
|
||||
if (plugins[pluginName] === undefined || typeof plugins[pluginName][setting] !== "string") continue;
|
||||
if (typeof plugins[pluginName][setting] !== "string") continue;
|
||||
logger.info(`Migrating setting ${setting} from ${pluginName} to list`);
|
||||
// @ts-ignore
|
||||
if (plugins[pluginName][setting] === "") plugins[pluginName][setting] = plugins[pluginName][setting].default ?? [];
|
||||
if (plugins[pluginName][setting] === "") plugins[pluginName][setting] = [];
|
||||
else if (typeof stringSeparator === "string") plugins[pluginName][setting] = plugins[pluginName][setting].split(stringSeparator);
|
||||
else plugins[pluginName][setting] = stringSeparator(plugins[pluginName][setting]);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import { classNameFactory } from "@api/Styles";
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import SearchModal from "@components/SearchModal";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { closeModal, openModal } from "@utils/modal";
|
||||
import { openModal } from "@utils/modal";
|
||||
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||
import { OptionType, PluginOptionArray } from "@utils/types";
|
||||
import { findByCodeLazy, findComponentByCodeLazy } from "@webpack";
|
||||
|
@ -104,14 +104,13 @@ export function SettingArrayComponent({
|
|||
}
|
||||
|
||||
function openSearchModal(val?: string) {
|
||||
const key = openModal(modalProps => (
|
||||
return openModal(modalProps => (
|
||||
<SearchModal
|
||||
modalProps={modalProps}
|
||||
close={() => closeModal(key)}
|
||||
input={val}
|
||||
subText={"All selected items will be added to " + wordsToTitle(wordsFromCamel(id))}
|
||||
searchType={option.type === OptionType.USERS ? "USERS" : option.type === OptionType.CHANNELS ? "CHANNELS" : "GUILDS"}
|
||||
onSubmit={v => console.log(v)}
|
||||
onSubmit={values => setItems([...items, ...values.map(v => v.id)])}
|
||||
/>
|
||||
));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings, migrateSettingsToArrays } from "@api/Settings";
|
||||
import { definePluginSettings, migratePluginSettings, migrateSettingsToArrays } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||
|
||||
|
@ -24,7 +24,7 @@ const NoopLogger = {
|
|||
|
||||
const logAllow = new Set();
|
||||
|
||||
migrateSettingsToArrays("consoleJanitor", ["whitelistedLoggers"], s => s.split(";").map(x => x.trim()));
|
||||
migrateSettingsToArrays("ConsoleJanitor", ["whitelistedLoggers"], s => s.split(";").map(x => x.trim()));
|
||||
|
||||
const settings = definePluginSettings({
|
||||
disableLoggers: {
|
||||
|
@ -59,7 +59,7 @@ export default definePlugin({
|
|||
startAt: StartAt.Init,
|
||||
start() {
|
||||
logAllow.clear();
|
||||
this.settings.store.whitelistedLoggers.forEach(logAllow.add.bind(logAllow));
|
||||
settings.store.whitelistedLoggers.forEach(logAllow.add.bind(logAllow));
|
||||
},
|
||||
|
||||
NoopLogger: () => NoopLogger,
|
||||
|
|
Loading…
Add table
Reference in a new issue