Fix Settings ContextMenu Shortcuts & Settings on canary

This commit is contained in:
Vendicated 2023-01-22 04:26:33 +01:00
parent 9602f527d8
commit b4f98e5066
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
2 changed files with 65 additions and 15 deletions

View file

@ -17,10 +17,12 @@
*/ */
import { Settings } from "@api/settings"; import { Settings } from "@api/settings";
import PatchHelper from "@components/PatchHelper";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import Logger from "@utils/Logger"; import Logger from "@utils/Logger";
import { LazyComponent } from "@utils/misc"; import { LazyComponent } from "@utils/misc";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Router } from "@webpack/common";
import gitHash from "~git-hash"; import gitHash from "~git-hash";
@ -62,23 +64,68 @@ export default definePlugin({
} }
} }
}, },
replace: (m, mod) => { replace: "...$self.makeSettingsCategories($1),$&"
const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Plugins.plugins.Settings.tabs.updater},' : "";
const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"Patch Helper",element:Vencord.Components.PatchHelper},' : "";
return (
`{section:${mod}.ID.HEADER,label:"Vencord"},` +
'{section:"VencordSettings",label:"Vencord",element:Vencord.Plugins.plugins.Settings.tabs.vencord},' +
'{section:"VencordPlugins",label:"Plugins",element:Vencord.Plugins.plugins.Settings.tabs.plugins},' +
'{section:"VencordThemes",label:"Themes",element:Vencord.Plugins.plugins.Settings.tabs.themes},' +
updater +
'{section:"VencordSettingsSync",label:"Backup & Restore",element:Vencord.Plugins.plugins.Settings.tabs.sync},' +
patchHelper +
`{section:${mod}.ID.DIVIDER},${m}`
);
}
} }
}], }],
makeSettingsCategories({ ID }: { ID: Record<string, unknown>; }) {
const makeOnClick = (tab: string) => () => Router.open(tab);
const cats = [
{
section: ID.HEADER,
label: "Vencord"
}, {
section: "VencordSettings",
label: "Vencord",
element: () => <SettingsComponent tab="VencordSettings" />,
onClick: makeOnClick("VencordSettings")
}, {
section: "VencordPlugins",
label: "Plugins",
element: () => <SettingsComponent tab="VencordPlugins" />,
onClick: makeOnClick("VencordPlugins")
}, {
section: "VencordThemes",
label: "Themes",
element: () => <SettingsComponent tab="VencordThemes" />,
onClick: makeOnClick("VencordThemes")
}
] as Array<{
section: unknown,
label?: string;
element?: React.ComponentType;
onClick?(): void;
}>;
if (!IS_WEB)
cats.push({
section: "VencordUpdater",
label: "Updater",
element: () => <SettingsComponent tab="VencordUpdater" />,
onClick: makeOnClick("VencordUpdater")
});
cats.push({
section: "VencordSettingsSync",
label: "Backup & Restore",
element: () => <SettingsComponent tab="VencordSettingsSync" />,
onClick: makeOnClick("VencordSettingsSync")
});
if (IS_DEV)
cats.push({
section: "VencordPatchHelper",
label: "Patch Helper",
element: PatchHelper!,
onClick: makeOnClick("VencordPatchHelper")
});
cats.push({ section: ID.DIVIDER });
return cats;
},
options: { options: {
settingsLocation: { settingsLocation: {
type: OptionType.SELECT, type: OptionType.SELECT,

View file

@ -182,7 +182,9 @@ waitFor(["getMember", "initialize"], m => GuildMemberStore = m);
waitFor("getRelationshipType", m => RelationshipStore = m); waitFor("getRelationshipType", m => RelationshipStore = m);
waitFor(["Hovers", "Looks", "Sizes"], m => Button = m); waitFor(["Hovers", "Looks", "Sizes"], m => Button = m);
waitFor(filters.byCode("helpdeskArticleId"), m => Switch = m);
waitFor(filters.byCode("tooltipNote", "ringTarget"), m => Switch = m);
waitFor(["Positions", "Colors"], m => Tooltip = m); waitFor(["Positions", "Colors"], m => Tooltip = m);
waitFor(m => m.Types?.PRIMARY === "cardPrimary", m => Card = m); waitFor(m => m.Types?.PRIMARY === "cardPrimary", m => Card = m);
@ -305,3 +307,4 @@ export const ContextMenu = mapMangledModuleLazy('type:"CONTEXT_MENU_OPEN"', {
export const MaskedLinkStore = mapMangledModuleLazy('"MaskedLinkStore"', { export const MaskedLinkStore = mapMangledModuleLazy('"MaskedLinkStore"', {
openUntrustedLink: filters.byCode(".apply(this,arguments)") openUntrustedLink: filters.byCode(".apply(this,arguments)")
}); });