mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-16 11:51:36 +00:00
30 lines
872 B
TypeScript
30 lines
872 B
TypeScript
import {ipcRenderer} from "electron";
|
|
|
|
import * as ConfigUtil from "../../../common/config-util";
|
|
|
|
import {focusCurrentServer} from "./helpers";
|
|
|
|
const NativeNotification = window.Notification;
|
|
export default class BaseNotification extends NativeNotification {
|
|
constructor(title: string, options: NotificationOptions) {
|
|
options.silent = true;
|
|
super(title, options);
|
|
|
|
this.addEventListener("click", () => {
|
|
// Focus to the server who sent the
|
|
// notification if not focused already
|
|
focusCurrentServer();
|
|
ipcRenderer.send("focus-app");
|
|
});
|
|
}
|
|
|
|
static async requestPermission(): Promise<NotificationPermission> {
|
|
return this.permission;
|
|
}
|
|
|
|
// Override default Notification permission
|
|
static get permission(): NotificationPermission {
|
|
return ConfigUtil.getConfigItem("showNotification") ? "granted" : "denied";
|
|
}
|
|
}
|