2022-08-31 02:07:16 +00:00
|
|
|
import { useSettings } from "../api/settings";
|
2022-10-17 19:18:25 +00:00
|
|
|
import { ChangeList } from "../utils/ChangeList";
|
2022-08-31 02:07:16 +00:00
|
|
|
import IpcEvents from "../utils/IpcEvents";
|
2022-10-17 19:18:25 +00:00
|
|
|
import { useAwaiter } from "../utils/misc";
|
|
|
|
import { Alerts, Button, Forms, Margins, Parser, React, Switch } from "../webpack/common";
|
2022-08-31 18:47:07 +00:00
|
|
|
import ErrorBoundary from "./ErrorBoundary";
|
2022-10-05 22:42:58 +00:00
|
|
|
import { Flex } from "./Flex";
|
2022-10-01 20:09:20 +00:00
|
|
|
|
|
|
|
export default ErrorBoundary.wrap(function Settings() {
|
2022-08-31 18:47:07 +00:00
|
|
|
const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke<string>(IpcEvents.GET_SETTINGS_DIR), "Loading...");
|
2022-08-31 02:07:16 +00:00
|
|
|
const settings = useSettings();
|
2022-10-04 10:57:39 +00:00
|
|
|
const changes = React.useMemo(() => new ChangeList<string>(), []);
|
2022-10-01 20:09:20 +00:00
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
return () => void (changes.hasChanges && Alerts.show({
|
|
|
|
title: "Restart required",
|
|
|
|
body: (
|
|
|
|
<>
|
|
|
|
<p>The following plugins require a restart:</p>
|
|
|
|
<div>{changes.map((s, i) => (
|
|
|
|
<>
|
|
|
|
{i > 0 && ", "}
|
2022-10-05 22:42:58 +00:00
|
|
|
{Parser.parse("`" + s + "`")}
|
2022-10-01 20:09:20 +00:00
|
|
|
</>
|
|
|
|
))}</div>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
confirmText: "Restart now",
|
|
|
|
cancelText: "Later!",
|
|
|
|
onConfirm: () => location.reload()
|
|
|
|
}));
|
|
|
|
}, []);
|
2022-08-31 02:07:16 +00:00
|
|
|
|
2022-09-03 15:49:16 +00:00
|
|
|
|
2022-08-31 02:07:16 +00:00
|
|
|
return (
|
|
|
|
<Forms.FormSection tag="h1" title="Vencord">
|
2022-10-01 20:09:20 +00:00
|
|
|
<Forms.FormTitle tag="h5">
|
2022-09-30 22:42:50 +00:00
|
|
|
Settings
|
|
|
|
</Forms.FormTitle>
|
|
|
|
|
|
|
|
<Forms.FormText>
|
2022-10-17 19:18:25 +00:00
|
|
|
Settings Directory: <code style={{ userSelect: "text", cursor: "text" }}>{settingsDir}</code>
|
2022-09-30 22:42:50 +00:00
|
|
|
</Forms.FormText>
|
|
|
|
|
2022-10-17 19:18:25 +00:00
|
|
|
{!IS_WEB && <Flex className={Margins.marginBottom20} style={{ marginTop: 8 }}>
|
2022-10-01 23:05:15 +00:00
|
|
|
<Button
|
2022-10-02 00:51:10 +00:00
|
|
|
onClick={() => window.DiscordNative.app.relaunch()}
|
2022-10-01 23:05:15 +00:00
|
|
|
size={Button.Sizes.SMALL}
|
|
|
|
color={Button.Colors.GREEN}
|
|
|
|
>
|
|
|
|
Reload
|
|
|
|
</Button>
|
2022-09-27 14:57:46 +00:00
|
|
|
<Button
|
2022-10-02 00:46:41 +00:00
|
|
|
onClick={() => window.DiscordNative.fileManager.showItemInFolder(settingsDir)}
|
2022-09-27 14:57:46 +00:00
|
|
|
size={Button.Sizes.SMALL}
|
|
|
|
disabled={settingsDirPending}
|
|
|
|
>
|
|
|
|
Launch Directory
|
|
|
|
</Button>
|
|
|
|
<Button
|
2022-10-03 17:17:54 +00:00
|
|
|
onClick={() => VencordNative.ipc.invoke(IpcEvents.OPEN_QUICKCSS)}
|
2022-09-27 14:57:46 +00:00
|
|
|
size={Button.Sizes.SMALL}
|
|
|
|
disabled={settingsDir === "Loading..."}
|
|
|
|
>
|
|
|
|
Open QuickCSS File
|
|
|
|
</Button>
|
2022-10-03 22:52:42 +00:00
|
|
|
</Flex>}
|
2022-10-16 15:15:15 +00:00
|
|
|
|
2022-10-01 23:05:15 +00:00
|
|
|
<Forms.FormDivider />
|
2022-09-03 15:49:16 +00:00
|
|
|
<Switch
|
|
|
|
value={settings.useQuickCss}
|
2022-10-01 23:05:15 +00:00
|
|
|
onChange={(v: boolean) => settings.useQuickCss = v}
|
2022-10-11 19:48:28 +00:00
|
|
|
note="Loads styles from your QuickCss file"
|
2022-09-03 15:49:16 +00:00
|
|
|
>
|
|
|
|
Use QuickCss
|
|
|
|
</Switch>
|
2022-10-11 19:48:28 +00:00
|
|
|
{!IS_WEB && <Switch
|
|
|
|
value={settings.enableReactDevtools}
|
|
|
|
onChange={(v: boolean) => settings.enableReactDevtools = v}
|
|
|
|
note="Requires a full restart"
|
|
|
|
>
|
|
|
|
Enable React Developer Tools
|
|
|
|
</Switch>}
|
2022-10-03 22:52:42 +00:00
|
|
|
{!IS_WEB && <Switch
|
2022-09-30 22:42:50 +00:00
|
|
|
value={settings.notifyAboutUpdates}
|
2022-10-01 23:05:15 +00:00
|
|
|
onChange={(v: boolean) => settings.notifyAboutUpdates = v}
|
2022-09-30 22:42:50 +00:00
|
|
|
note="Shows a Toast on StartUp"
|
|
|
|
>
|
|
|
|
Get notified about new Updates
|
2022-10-03 22:52:42 +00:00
|
|
|
</Switch>}
|
2022-08-31 02:07:16 +00:00
|
|
|
</Forms.FormSection >
|
|
|
|
);
|
2022-09-16 20:59:34 +00:00
|
|
|
});
|