diff --git a/src/Toaster.js b/src/Toaster.js deleted file mode 100644 index bf8a8f49db3b..000000000000 --- a/src/Toaster.js +++ /dev/null @@ -1,66 +0,0 @@ -import { BrowserWindow, ipcMain, screen } from 'electron'; - -export default class Toaster { - constructor (mainWindow, maxNotifications = 3, debug = false) { - this.mainWindow = mainWindow; - this.debug = debug; - this.maxNotifications = maxNotifications; - this.windows = []; - } - - toast (msg, callback) { - const window = new BrowserWindow({ - width: msg.width, - height: 75, - transparent: true, - frame: false, - show : false, - alwaysOnTop: true, - skipTaskbar: true, - resizable: false, - focusable: false - }); - - if (this.debug) { - window.openDevTools(); - } - - this.windows.push(window); - - ipcMain.once(`notification-${msg.tag}`, callback); - - window.on('closed', () => { - this.windows = this.windows.filter((win) => win && !win.isDestroyed() && win !== window); - this.windows.forEach((win, i) => this._setPosition(win, i + 1)); - }); - - const htmlFile = `${msg.htmlFile}?` + - `title=${encodeURIComponent(msg.title || '')}&` + - `message=${encodeURIComponent(msg.message || '')}&` + - `timeout=${msg.timeout}&` + - `icon=${encodeURIComponent(msg.icon)}&` + - `tag=${encodeURIComponent(msg.tag)}`; - - window.loadURL(htmlFile); - - window.webContents.on('did-finish-load', () => { - this._setPosition(window, this.windows.length); - }); - } - - _setPosition (window, index) { - const [ notificationWidth, notificationHeight ] = window.getSize(); - const [ appX, appY ] = this.mainWindow.getPosition(); - const { x, y, width, height } = screen.getDisplayNearestPoint({x: appX, y: appY}).workArea; - const margin = 5; - const notificationX = x + width - notificationWidth - margin; - const notificationDistance = notificationHeight + margin; - const notificationY = y + height - (notificationDistance * index); - - window.setPosition(notificationX, notificationY); - - if (index <= this.maxNotifications) { - window.showInactive(); - } - } -} diff --git a/src/background.custom.js b/src/background.custom.js index 1b89c72e385c..376aec2375f7 100644 --- a/src/background.custom.js +++ b/src/background.custom.js @@ -3,11 +3,9 @@ // It doesn't have any windows which you can see on screen, but we can open // window from here. -import os from 'os'; import { app, ipcMain, BrowserWindow } from 'electron'; import windowStateKeeper from './background/windowState'; import certificate from './background/certificate'; -import Toaster from './Toaster'; import idle from '@paulcbetts/system-idle-time'; import { checkForUpdates } from './background/autoUpdate'; @@ -132,26 +130,6 @@ export function afterMainWindow (mainWindow) { event.returnValue = idle.getIdleTime(); }); - // Windows 7 and below - const useToaster = ['win32', 'win64'].indexOf(os.platform()) !== -1 && - parseFloat(os.release()) < 6.2; - - if (useToaster) { - const toaster = new Toaster(mainWindow); - - ipcMain.on('notification-shim', (e, title, options) => { - toaster.toast({ - title: title, - message: options.body, - icon: options.icon, - tag: options.tag, - width: 400, - timeout: 5000, - htmlFile: 'file://'+__dirname+'/public/notification.html' - }, () => e.sender.send(`clicked-${options.tag}`)); - }); - } - certificate.initWindow(mainWindow); checkForUpdates(); diff --git a/src/public/lib/Notification.js b/src/public/lib/Notification.js index cd5562fbfd28..5714be6a5611 100644 --- a/src/public/lib/Notification.js +++ b/src/public/lib/Notification.js @@ -4,10 +4,6 @@ class Notification extends window.Notification { constructor (title, options) { super(title, options); - ipcRenderer.send('notification-shim', title, options); - - // Handle correct notification using unique tag - ipcRenderer.once(`clicked-${options.tag}`, () => this.onclick()); } get onclick () { diff --git a/src/public/notification.html b/src/public/notification.html deleted file mode 100644 index 8310e73ef13f..000000000000 --- a/src/public/notification.html +++ /dev/null @@ -1,193 +0,0 @@ - - - - Toaster - - - -
-
-
- -
-
-

-

-
- - - × - -
-
- - -