aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinto <48173186+X1nto@users.noreply.github.com>2023-03-19 13:21:26 +0400
committerGitHub <noreply@github.com>2023-03-19 09:21:26 +0000
commit4aff11421f1cccaf34a7c983fd8dc9a841042947 (patch)
treee7313c34ddf2312493a86afd6f7309a3c81f7e63
parentea642d9e901d42f0f5f73ba1f9cfeb3d1e595332 (diff)
downloadVencord-4aff11421f1cccaf34a7c983fd8dc9a841042947.tar.gz
Vencord-4aff11421f1cccaf34a7c983fd8dc9a841042947.tar.bz2
Vencord-4aff11421f1cccaf34a7c983fd8dc9a841042947.zip
Replace update notices with notifications (#558)
-rw-r--r--src/Vencord.ts34
-rw-r--r--src/api/settings.ts2
-rw-r--r--src/components/VencordSettings/Updater.tsx12
3 files changed, 28 insertions, 20 deletions
diff --git a/src/Vencord.ts b/src/Vencord.ts
index ba7d01f..98bc83a 100644
--- a/src/Vencord.ts
+++ b/src/Vencord.ts
@@ -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);
}
diff --git a/src/api/settings.ts b/src/api/settings.ts
index 1ca2611..0ebfe1d 100644
--- a/src/api/settings.ts
+++ b/src/api/settings.ts
@@ -28,6 +28,7 @@ const logger = new Logger("Settings");
export interface Settings {
notifyAboutUpdates: boolean;
autoUpdate: boolean;
+ autoUpdateNotification: boolean,
useQuickCss: boolean;
enableReactDevtools: boolean;
themeLinks: string[];
@@ -52,6 +53,7 @@ export interface Settings {
const DefaultSettings: Settings = {
notifyAboutUpdates: true,
autoUpdate: false,
+ autoUpdateNotification: true,
useQuickCss: true,
themeLinks: [],
enableReactDevtools: false,
diff --git a/src/components/VencordSettings/Updater.tsx b/src/components/VencordSettings/Updater.tsx
index caed4f7..3c3eb91 100644
--- a/src/components/VencordSettings/Updater.tsx
+++ b/src/components/VencordSettings/Updater.tsx
@@ -185,7 +185,7 @@ function Newer(props: CommonProps) {
}
function Updater() {
- const settings = useSettings(["notifyAboutUpdates", "autoUpdate"]);
+ const settings = useSettings(["notifyAboutUpdates", "autoUpdate", "autoUpdateNotification"]);
const [repo, err, repoPending] = useAwaiter(getRepo, { fallbackValue: "Loading..." });
@@ -205,7 +205,7 @@ function Updater() {
<Switch
value={settings.notifyAboutUpdates}
onChange={(v: boolean) => settings.notifyAboutUpdates = v}
- note="Shows a toast on startup"
+ note="Shows a notification on startup"
disabled={settings.autoUpdate}
>
Get notified about new updates
@@ -217,6 +217,14 @@ function Updater() {
>
Automatically update
</Switch>
+ <Switch
+ value={settings.autoUpdateNotification}
+ onChange={(v: boolean) => settings.autoUpdateNotification = v}
+ note="Shows a notification when Vencord automatically updates"
+ disabled={!settings.autoUpdate}
+ >
+ Get notified when an automatic update completes
+ </Switch>
<Forms.FormTitle tag="h5">Repo</Forms.FormTitle>