From 52211095aab71f8b59b093b19ae34c222be9f390 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Thu, 14 Oct 2021 09:32:20 +0200 Subject: chore: convert various JS to TS (#2062) --- src/webview/notifications.js | 71 -------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 src/webview/notifications.js (limited to 'src/webview/notifications.js') diff --git a/src/webview/notifications.js b/src/webview/notifications.js deleted file mode 100644 index 22960d818..000000000 --- a/src/webview/notifications.js +++ /dev/null @@ -1,71 +0,0 @@ -import { ipcRenderer } from 'electron'; - -import { v1 as uuidV1 } from 'uuid'; - -const debug = require('debug')('Ferdi:Notifications'); - -export class NotificationsHandler { - onNotify = data => data; - - displayNotification(title, options) { - return new Promise(resolve => { - debug('New notification', title, options); - - const notificationId = uuidV1(); - - ipcRenderer.sendToHost( - 'notification', - this.onNotify({ - title, - options, - notificationId, - }), - ); - - ipcRenderer.once(`notification-onclick:${notificationId}`, () => { - resolve(); - }); - }); - } -} - -export const notificationsClassDefinition = `(() => { - class Notification { - static permission = 'granted'; - - constructor(title = '', options = {}) { - this.title = title; - this.options = options; - window.ferdi.displayNotification(title, options) - .then(() => { - if (typeof (this.onClick) === 'function') { - this.onClick(); - } - }); - } - - static requestPermission(cb = null) { - if (!cb) { - return new Promise((resolve) => { - resolve(Notification.permission); - }); - } - - if (typeof (cb) === 'function') { - return cb(Notification.permission); - } - - return Notification.permission; - } - - onNotify(data) { - return data; - } - - onClick() {} - - close() {} - } - - window.Notification = Notification; -})();`; -- cgit v1.2.3-54-g00ecf