Browse Source

Use only one silent_Notification for all platforms

reviewable/pr226/r3
Albert Huang 6 years ago
parent
commit
5191b66a93
  1. 2
      src/inject/darwin/index.js
  2. 2
      src/inject/linux/index.js
  3. 40
      src/inject/linux/silent_Notification.js
  4. 0
      src/inject/silent_Notification.js
  5. 2
      src/inject/win32/polyfill_Notification.js

2
src/inject/darwin/index.js

@ -1 +1 @@
import './silent_Notification';
import '../silent_Notification';

2
src/inject/linux/index.js

@ -1 +1 @@
import './silent_Notification';
import '../silent_Notification';

40
src/inject/linux/silent_Notification.js

@ -1,40 +0,0 @@
window._Notification = window.Notification;
class SilentNotification {
constructor(title, options) {
const opts = options;
opts.silent = true;
this._notification = new window._Notification(title, opts);
this.title = this._notification.title;
this.dir = this._notification.dir;
this.lang = this._notification.lang;
this.body = this._notification.body;
this.tag = this._notification.tag;
this.icon = this._notification.icon;
this.data = this._notification.data;
this.requireInteraction = false;
this.silent = true;
Object.defineProperty(this, 'onclick', {
get: () => { return this._notification.onclick; },
set: (fn) => { this._notification.onclick = fn; },
configurable: true,
enumerable: true,
});
Object.defineProperty(this, 'onerror', {
get: () => { return this._notification.onerror; },
set: (fn) => { this._notification.onerror = fn; },
configurable: true,
enumerable: true,
});
}
close() {
this._notification.close();
}
}
SilentNotification.permission = 'granted';
window.Notification = SilentNotification;

0
src/inject/darwin/silent_Notification.js → src/inject/silent_Notification.js

2
src/inject/win32/polyfill_Notification.js

@ -5,7 +5,7 @@ const osVersion = os.release().split('.');
if (osVersion[0] && parseInt(osVersion[0], 10) > 7) {
// If we are above windows 7 we can use the system notifications but with
// the silent flag forced on
require('../darwin/silent_Notification');
require('../silent_Notification');
} else {
const NOTIFICATIONS = [];

Loading…
Cancel
Save