Replace update notices with notifications (#558)

This commit is contained in:
Xinto 2023-03-19 13:21:26 +04:00 committed by GitHub
parent ea642d9e90
commit 4aff11421f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 20 deletions

View file

@ -27,7 +27,7 @@ export { PlainSettings, Settings };
import "./utils/quickCss";
import "./webpack/patchWebpack";
import { popNotice, showNotice } from "./api/Notices";
import { showNotification } from "./api/Notifications";
import { PlainSettings, Settings } from "./api/settings";
import { patches, PMLogger, startAllPlugins } from "./plugins";
import { checkForUpdates, rebuild, update, UpdateLogger } from "./utils/updater";
@ -49,32 +49,30 @@ async function init() {
if (Settings.autoUpdate) {
await update();
const needsFullRestart = await rebuild();
setTimeout(() => {
showNotice(
"Vencord has been updated!",
"Restart",
() => {
if (Settings.autoUpdateNotification)
showNotification({
title: "Vencord has been updated!",
body: "Click here to restart",
permanent: true,
onClick() {
if (needsFullRestart)
window.DiscordNative.app.relaunch();
else
location.reload();
}
);
}, 10_000);
});
return;
}
if (Settings.notifyAboutUpdates)
setTimeout(() => {
showNotice(
"A Vencord update is available!",
"View Update",
() => {
popNotice();
SettingsRouter.open("VencordUpdater");
}
);
}, 10_000);
showNotification({
title: "A Vencord update is available!",
body: "Click here to view the update",
permanent: true,
onClick() {
SettingsRouter.open("VencordUpdater");
}
});
} catch (err) {
UpdateLogger.error("Failed to check for updates", err);
}