mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-24 00:23:36 +00:00
31 lines
879 B
JavaScript
31 lines
879 B
JavaScript
'use strict';
|
|
|
|
const { remote } = require('electron');
|
|
|
|
const ConfigUtil = require(__dirname + '/utils/config-util.js');
|
|
|
|
const app = remote.app;
|
|
|
|
// From https://github.com/felixrieseberg/electron-windows-notifications#appusermodelid
|
|
// On windows 8 we have to explicitly set the appUserModelId otherwise notification won't work.
|
|
app.setAppUserModelId('org.zulip.zulip-electron');
|
|
|
|
const NativeNotification = window.Notification;
|
|
|
|
class baseNotification extends NativeNotification {
|
|
constructor(title, opts) {
|
|
opts.silent = ConfigUtil.getConfigItem('silent') || false;
|
|
super(title, opts);
|
|
}
|
|
static requestPermission() {
|
|
return; // eslint-disable-line no-useless-return
|
|
}
|
|
// Override default Notification permission
|
|
static get permission() {
|
|
return ConfigUtil.getConfigItem('showNotification') ? 'granted' : 'denied';
|
|
}
|
|
}
|
|
|
|
window.Notification = baseNotification;
|
|
|