fix: add predicate to updater menu item (#266)

* fix: add predicate to updater menu item

* dont include Updater in web builds

* i can spell
This commit is contained in:
megumin 2022-11-27 15:07:31 +00:00 committed by GitHub
parent 47c181beec
commit 4fc41c8c0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,19 +39,25 @@ interface SettingsProps {
tab: string; tab: string;
} }
const SettingsTabs = { interface SettingsTab {
name: string;
component?: React.ComponentType;
}
const SettingsTabs: Record<string, SettingsTab> = {
VencordSettings: { name: "Vencord", component: () => <VencordSettings /> }, VencordSettings: { name: "Vencord", component: () => <VencordSettings /> },
VencordPlugins: { name: "Plugins", component: () => <PluginsTab /> }, VencordPlugins: { name: "Plugins", component: () => <PluginsTab /> },
VencordThemes: { name: "Themes", component: () => <Text variant="text-md/medium">Coming soon to a Vencord near you!</Text> }, VencordThemes: { name: "Themes", component: () => <Text variant="text-md/medium">Coming soon to a Vencord near you!</Text> },
VencordUpdater: { name: "Updater", component: () => Updater ? <Updater /> : null }, VencordUpdater: { name: "Updater" }, // Only show updater if IS_WEB is false
VencordSettingsSync: { name: "Backup & Restore", component: () => <BackupRestoreTab /> }, VencordSettingsSync: { name: "Backup & Restore", component: () => <BackupRestoreTab /> },
}; };
if (!IS_WEB) SettingsTabs.VencordUpdater.component = () => Updater && <Updater />;
function Settings(props: SettingsProps) { function Settings(props: SettingsProps) {
const { tab = "VencordSettings" } = props; const { tab = "VencordSettings" } = props;
const CurrentTab = SettingsTabs[tab]?.component ?? null; const CurrentTab = SettingsTabs[tab]?.component;
return <Forms.FormSection> return <Forms.FormSection>
<Text variant="heading-md/normal" tag="h2">Vencord Settings</Text> <Text variant="heading-md/normal" tag="h2">Vencord Settings</Text>
@ -63,7 +69,8 @@ function Settings(props: SettingsProps) {
selectedItem={tab} selectedItem={tab}
onItemSelect={Router.open} onItemSelect={Router.open}
> >
{Object.entries(SettingsTabs).map(([key, { name }]) => { {Object.entries(SettingsTabs).map(([key, { name, component }]) => {
if (!component) return null;
return <TabBar.Item return <TabBar.Item
id={key} id={key}
className={st("TabBarItem")} className={st("TabBarItem")}
@ -73,7 +80,7 @@ function Settings(props: SettingsProps) {
})} })}
</TabBar> </TabBar>
<Forms.FormDivider /> <Forms.FormDivider />
<CurrentTab /> {CurrentTab && <CurrentTab />}
</Forms.FormSection >; </Forms.FormSection >;
} }