Merge pull request #3709 from t3chguy/electron_notification_causes_weirdness_onclick
Electron forgets it was maximized when you click on a notification
This commit is contained in:
commit
ef057e4693
|
@ -24,12 +24,12 @@ import q from 'q';
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const remote = electron.remote;
|
const remote = electron.remote;
|
||||||
|
|
||||||
electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);
|
remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);
|
||||||
|
|
||||||
function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
|
function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'new_version',
|
action: 'new_version',
|
||||||
currentVersion: electron.remote.app.getVersion(),
|
currentVersion: remote.app.getVersion(),
|
||||||
newVersion: ver,
|
newVersion: ver,
|
||||||
releaseNotes: releaseNotes,
|
releaseNotes: releaseNotes,
|
||||||
});
|
});
|
||||||
|
@ -68,7 +68,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
try {
|
try {
|
||||||
remote.app.setBadgeCount(count);
|
remote.app.setBadgeCount(count);
|
||||||
} catch (e) {
|
} 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 &
|
// 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.
|
// so we shouldn't assume that all implementations will treat those properly. Very basic tag parsing is done.
|
||||||
if (window.process.platform === 'linux') {
|
if (window.process.platform === 'linux') {
|
||||||
msg = msg.replace(/</g, "<").replace(/>/g, ">");
|
msg = msg.replace(/</g, '<').replace(/>/g, '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notifications in Electron use the HTML5 notification API
|
// Notifications in Electron use the HTML5 notification API
|
||||||
|
@ -98,7 +98,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
{
|
{
|
||||||
body: msg,
|
body: msg,
|
||||||
icon: avatarUrl,
|
icon: avatarUrl,
|
||||||
tag: "vector",
|
tag: 'vector',
|
||||||
silent: true, // we play our own sounds
|
silent: true, // we play our own sounds
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -106,13 +106,14 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
notification.onclick = function() {
|
notification.onclick = function() {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room',
|
action: 'view_room',
|
||||||
room_id: room.roomId
|
room_id: room.roomId,
|
||||||
});
|
});
|
||||||
global.focus();
|
global.focus();
|
||||||
const currentWin = electron.remote.getCurrentWindow();
|
const win = remote.getCurrentWindow();
|
||||||
currentWin.show();
|
|
||||||
currentWin.restore();
|
if (win.isMinimized()) win.restore();
|
||||||
currentWin.focus();
|
else if (!win.isVisible()) win.show();
|
||||||
|
else win.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
return notification;
|
return notification;
|
||||||
|
@ -123,7 +124,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppVersion() {
|
getAppVersion() {
|
||||||
return q(electron.remote.app.getVersion());
|
return q(remote.app.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
pollForUpdate() {
|
pollForUpdate() {
|
||||||
|
@ -140,7 +141,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultDeviceDisplayName() {
|
getDefaultDeviceDisplayName() {
|
||||||
return "Riot Desktop on " + platformFriendlyName();
|
return 'Riot Desktop on ' + platformFriendlyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
screenCaptureErrorString() {
|
screenCaptureErrorString() {
|
||||||
|
@ -152,6 +153,6 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
electron.remote.getCurrentWebContents().reload();
|
remote.getCurrentWebContents().reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue