From 2139fb74bbbd3c7f1865efd49342029939393584 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 23 Apr 2017 09:56:43 +0100 Subject: [PATCH 1/2] change show logic to same as that of the tray icon Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index b0928a8f..21d324a4 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -106,13 +106,14 @@ export default class ElectronPlatform extends VectorBasePlatform { notification.onclick = function() { dis.dispatch({ action: 'view_room', - room_id: room.roomId + room_id: room.roomId, }); global.focus(); - const currentWin = electron.remote.getCurrentWindow(); - currentWin.show(); - currentWin.restore(); - currentWin.focus(); + const win = electron.remote.getCurrentWindow(); + + if (win.isMinimized()) win.restore(); + else if (!win.isVisible()) win.show(); + else win.focus(); }; return notification; From b3c9229aeeae48620a1a8164dc1f1eb1cdef8cfb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 23 Apr 2017 09:59:00 +0100 Subject: [PATCH 2/2] DRY code and change double quotes to single Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 21d324a4..9c857e35 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -24,12 +24,12 @@ import q from 'q'; const electron = require('electron'); const remote = electron.remote; -electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded); +remote.autoUpdater.on('update-downloaded', onUpdateDownloaded); function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) { dis.dispatch({ action: 'new_version', - currentVersion: electron.remote.app.getVersion(), + currentVersion: remote.app.getVersion(), newVersion: ver, releaseNotes: releaseNotes, }); @@ -68,7 +68,7 @@ export default class ElectronPlatform extends VectorBasePlatform { try { remote.app.setBadgeCount(count); } catch (e) { - console.error("Failed to set notification count", e); + console.error('Failed to set notification count', e); } } @@ -89,7 +89,7 @@ export default class ElectronPlatform extends VectorBasePlatform { // we only have to strip out < and > as the spec doesn't include anything about things like & // so we shouldn't assume that all implementations will treat those properly. Very basic tag parsing is done. if (window.process.platform === 'linux') { - msg = msg.replace(//g, ">"); + msg = msg.replace(//g, '>'); } // Notifications in Electron use the HTML5 notification API @@ -98,7 +98,7 @@ export default class ElectronPlatform extends VectorBasePlatform { { body: msg, icon: avatarUrl, - tag: "vector", + tag: 'vector', silent: true, // we play our own sounds } ); @@ -109,7 +109,7 @@ export default class ElectronPlatform extends VectorBasePlatform { room_id: room.roomId, }); global.focus(); - const win = electron.remote.getCurrentWindow(); + const win = remote.getCurrentWindow(); if (win.isMinimized()) win.restore(); else if (!win.isVisible()) win.show(); @@ -124,7 +124,7 @@ export default class ElectronPlatform extends VectorBasePlatform { } getAppVersion() { - return q(electron.remote.app.getVersion()); + return q(remote.app.getVersion()); } pollForUpdate() { @@ -141,7 +141,7 @@ export default class ElectronPlatform extends VectorBasePlatform { } getDefaultDeviceDisplayName() { - return "Riot Desktop on " + platformFriendlyName(); + return 'Riot Desktop on ' + platformFriendlyName(); } screenCaptureErrorString() { @@ -153,6 +153,6 @@ export default class ElectronPlatform extends VectorBasePlatform { } reload() { - electron.remote.getCurrentWebContents().reload(); + remote.getCurrentWebContents().reload(); } }