Vesktop/src/renderer/fixes.ts

34 lines
977 B
TypeScript
Raw Normal View History

2023-04-09 22:49:50 +02:00
/*
* SPDX-License-Identifier: GPL-3.0
2023-07-13 19:03:13 +02:00
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
2023-04-09 22:49:50 +02:00
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
2023-04-05 05:31:44 +02:00
import "./hideGarbage.css";
2023-04-09 22:49:50 +02:00
2023-04-19 22:47:47 +02:00
import { waitFor } from "@vencord/types/webpack";
2023-04-05 20:01:31 +02:00
import { isFirstRun, localStorage } from "./utils";
2023-04-05 05:31:44 +02:00
// Make clicking Notifications focus the window
const originalSetOnClick = Object.getOwnPropertyDescriptor(Notification.prototype, "onclick")!.set!;
Object.defineProperty(Notification.prototype, "onclick", {
set(onClick) {
2023-04-05 16:56:33 +02:00
originalSetOnClick.call(this, function (this: unknown) {
onClick.apply(this, arguments);
2023-07-13 19:03:13 +02:00
VesktopNative.win.focus();
});
},
configurable: true
});
if (isFirstRun) {
2023-04-05 20:01:31 +02:00
// Hide "Download Discord Desktop now!!!!" banner
localStorage.setItem("hideNag", "true");
2023-06-26 00:41:52 +02:00
// Enable Desktop Notifications by default
2023-04-19 22:47:47 +02:00
waitFor("setDesktopType", m => {
m.setDesktopType("all");
});
}