mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +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[]) = ",") {
|
export function migrateSettingsToArrays(pluginName: string, settings: string[], stringSeparator: string | ((input: string) => string[]) = ",") {
|
||||||
const { plugins } = SettingsStore.plain;
|
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) {
|
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`);
|
logger.info(`Migrating setting ${setting} from ${pluginName} to list`);
|
||||||
// @ts-ignore
|
if (plugins[pluginName][setting] === "") plugins[pluginName][setting] = [];
|
||||||
if (plugins[pluginName][setting] === "") plugins[pluginName][setting] = plugins[pluginName][setting].default ?? [];
|
|
||||||
else if (typeof stringSeparator === "string") plugins[pluginName][setting] = plugins[pluginName][setting].split(stringSeparator);
|
else if (typeof stringSeparator === "string") plugins[pluginName][setting] = plugins[pluginName][setting].split(stringSeparator);
|
||||||
else plugins[pluginName][setting] = stringSeparator(plugins[pluginName][setting]);
|
else plugins[pluginName][setting] = stringSeparator(plugins[pluginName][setting]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import SearchModal from "@components/SearchModal";
|
import SearchModal from "@components/SearchModal";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { closeModal, openModal } from "@utils/modal";
|
import { openModal } from "@utils/modal";
|
||||||
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||||
import { OptionType, PluginOptionArray } from "@utils/types";
|
import { OptionType, PluginOptionArray } from "@utils/types";
|
||||||
import { findByCodeLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByCodeLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
|
@ -104,14 +104,13 @@ export function SettingArrayComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
function openSearchModal(val?: string) {
|
function openSearchModal(val?: string) {
|
||||||
const key = openModal(modalProps => (
|
return openModal(modalProps => (
|
||||||
<SearchModal
|
<SearchModal
|
||||||
modalProps={modalProps}
|
modalProps={modalProps}
|
||||||
close={() => closeModal(key)}
|
|
||||||
input={val}
|
input={val}
|
||||||
subText={"All selected items will be added to " + wordsToTitle(wordsFromCamel(id))}
|
subText={"All selected items will be added to " + wordsToTitle(wordsFromCamel(id))}
|
||||||
searchType={option.type === OptionType.USERS ? "USERS" : option.type === OptionType.CHANNELS ? "CHANNELS" : "GUILDS"}
|
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
|
* 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 { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ const NoopLogger = {
|
||||||
|
|
||||||
const logAllow = new Set();
|
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({
|
const settings = definePluginSettings({
|
||||||
disableLoggers: {
|
disableLoggers: {
|
||||||
|
@ -59,7 +59,7 @@ export default definePlugin({
|
||||||
startAt: StartAt.Init,
|
startAt: StartAt.Init,
|
||||||
start() {
|
start() {
|
||||||
logAllow.clear();
|
logAllow.clear();
|
||||||
this.settings.store.whitelistedLoggers.forEach(logAllow.add.bind(logAllow));
|
settings.store.whitelistedLoggers.forEach(logAllow.add.bind(logAllow));
|
||||||
},
|
},
|
||||||
|
|
||||||
NoopLogger: () => NoopLogger,
|
NoopLogger: () => NoopLogger,
|
||||||
|
|
Loading…
Add table
Reference in a new issue