mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-24 08:33:36 +00:00
To satisfy unicorn/prevent-abbreviations in xo 0.28. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
29 lines
837 B
TypeScript
29 lines
837 B
TypeScript
import { ipcRenderer } from 'electron';
|
|
import { focusCurrentServer } from './helpers';
|
|
|
|
import * as ConfigUtil from '../utils/config-util';
|
|
|
|
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';
|
|
}
|
|
}
|