Enable Desktop Notifications on first run

This commit is contained in:
Vendicated 2023-04-05 16:51:19 +02:00
parent d9f2b15e84
commit 9d144a11be
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
4 changed files with 18 additions and 0 deletions

2
src/globals.d.ts vendored
View file

@ -1,5 +1,7 @@
declare global {
export var VencordDesktop: typeof import("./preload/VencordDesktop").VencordDesktop;
// TODO
export var Vencord: any;
}
export { };

View file

@ -0,0 +1 @@
export const localStorage = window.localStorage;

View file

@ -1,4 +1,5 @@
import "./hideGarbage.css";
import { isFirstRun } from "./utilts";
// Make clicking Notifications focus the window
const originalSetOnClick = Object.getOwnPropertyDescriptor(Notification.prototype, "onclick")!.set!;
@ -11,3 +12,9 @@ Object.defineProperty(Notification.prototype, "onclick", {
},
configurable: true
});
if (isFirstRun) {
Vencord.Webpack.waitFor("setDesktopType", m => {
m.setDesktopType("all");
});
}

8
src/renderer/utilts.ts Normal file
View file

@ -0,0 +1,8 @@
export const localStorage = window.localStorage;
export const isFirstRun = (() => {
const key = "VCD_FIRST_RUN";
if (localStorage.getItem(key) !== null) return false;
localStorage.setItem(key, "false");
return true;
})();