Make Windows Ctrl+Q feature optional; add opt-in auto update (#451)

This commit is contained in:
Ven 2023-01-24 01:42:57 +01:00 committed by GitHub
parent 25d32ce292
commit b2ecb02335
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 33 deletions

View file

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { useSettings } from "@api/settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { ErrorCard } from "@components/ErrorCard";
import { Flex } from "@components/Flex";
@ -23,7 +24,7 @@ import { handleComponentFailed } from "@components/handleComponentFailed";
import { Link } from "@components/Link";
import { classes, useAwaiter } from "@utils/misc";
import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "@utils/updater";
import { Alerts, Button, Card, Forms, Margins, Parser, React, Toasts } from "@webpack/common";
import { Alerts, Button, Card, Forms, Margins, Parser, React, Switch, Toasts } from "@webpack/common";
import gitHash from "~git-hash";
@ -183,6 +184,8 @@ function Newer(props: CommonProps) {
}
function Updater() {
const settings = useSettings(["notifyAboutUpdates", "autoUpdate"]);
const [repo, err, repoPending] = useAwaiter(getRepo, { fallbackValue: "Loading..." });
React.useEffect(() => {
@ -197,6 +200,23 @@ function Updater() {
return (
<Forms.FormSection>
<Forms.FormTitle tag="h5">Updater Settings</Forms.FormTitle>
<Switch
value={settings.notifyAboutUpdates}
onChange={(v: boolean) => settings.notifyAboutUpdates = v}
note="Shows a toast on startup"
disabled={settings.autoUpdate}
>
Get notified about new updates
</Switch>
<Switch
value={settings.autoUpdate}
onChange={(v: boolean) => settings.autoUpdate = v}
note="Automatically update Vencord without confirmation prompt"
>
Automatically update
</Switch>
<Forms.FormTitle tag="h5">Repo</Forms.FormTitle>
<Forms.FormText>{repoPending ? repo : err ? "Failed to retrieve - check console" : (

View file

@ -97,21 +97,26 @@ function VencordSettings() {
<Switch
value={settings.enableReactDevtools}
onChange={(v: boolean) => settings.enableReactDevtools = v}
note="Requires a full restart">
note="Requires a full restart"
>
Enable React Developer Tools
</Switch>
<Switch
value={settings.notifyAboutUpdates}
onChange={(v: boolean) => settings.notifyAboutUpdates = v}
note="Shows a toast on startup">
Get notified about new updates
</Switch>
<Switch
value={settings.frameless}
onChange={(v: boolean) => settings.frameless = v}
note="Requires a full restart">
note="Requires a full restart"
>
Disable the window frame
</Switch>
{navigator.platform.toLowerCase().startsWith("win") && (
<Switch
value={settings.winCtrlQ}
onChange={(v: boolean) => settings.winCtrlQ = v}
note="Requires a full restart"
>
Register Ctrl+Q as shortcut to close Discord (Alternative to Alt+F4)
</Switch>
)}
</React.Fragment>
)}