Files
zulip-desktop/app/renderer/js/notification/default-notification.ts
Anders Kaseorg 67228d295d Reformat all code with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-31 20:04:00 -07:00

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";
}
}