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

@ -30,7 +30,7 @@ import "./webpack/patchWebpack";
import { popNotice, showNotice } from "./api/Notices";
import { PlainSettings, Settings } from "./api/settings";
import { patches, PMLogger, startAllPlugins } from "./plugins";
import { checkForUpdates, UpdateLogger } from "./utils/updater";
import { checkForUpdates, rebuild, update, UpdateLogger } from "./utils/updater";
import { onceReady } from "./webpack";
import { Router } from "./webpack/common";
@ -44,7 +44,27 @@ async function init() {
if (!IS_WEB) {
try {
const isOutdated = await checkForUpdates();
if (isOutdated && Settings.notifyAboutUpdates)
if (!isOutdated) return;
if (Settings.autoUpdate) {
await update();
const needsFullRestart = await rebuild();
setTimeout(() => {
showNotice(
"Vencord has been updated!",
"Restart",
() => {
if (needsFullRestart)
window.DiscordNative.app.relaunch();
else
location.reload();
}
);
}, 10_000);
return;
}
if (Settings.notifyAboutUpdates)
setTimeout(() => {
showNotice(
"A Vencord update is available!",
@ -54,7 +74,7 @@ async function init() {
Router.open("VencordUpdater");
}
);
}, 10000);
}, 10_000);
} catch (err) {
UpdateLogger.error("Failed to check for updates", err);
}