mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-228 - Added an event to terminate screen snippet process whenever the main window is reloaded/navigated
This commit is contained in:
@@ -16,6 +16,7 @@ const cmds = keyMirror({
|
|||||||
registerProtocolHandler: null,
|
registerProtocolHandler: null,
|
||||||
registerActivityDetection: null,
|
registerActivityDetection: null,
|
||||||
showNotificationSettings: null,
|
showNotificationSettings: null,
|
||||||
|
reload: null
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ const activityDetection = require('./activityDetection');
|
|||||||
const badgeCount = require('./badgeCount.js');
|
const badgeCount = require('./badgeCount.js');
|
||||||
const protocolHandler = require('./protocolHandler');
|
const protocolHandler = require('./protocolHandler');
|
||||||
const configureNotification = require('./notify/settings/configure-notification-position');
|
const configureNotification = require('./notify/settings/configure-notification-position');
|
||||||
|
const eventEmitter = require('./eventEmitter');
|
||||||
|
const { isMac } = require('./utils/misc');
|
||||||
|
|
||||||
const apiEnums = require('./enums/api.js');
|
const apiEnums = require('./enums/api.js');
|
||||||
const apiCmds = apiEnums.cmds;
|
const apiCmds = apiEnums.cmds;
|
||||||
@@ -47,6 +49,24 @@ function isValidWindow(event) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that is invoked when the application is reloaded/navigated
|
||||||
|
* window.addEventListener('beforeunload')
|
||||||
|
* @param windowName
|
||||||
|
*/
|
||||||
|
function reload(windowName) {
|
||||||
|
// To make sure the reload event is from the main window
|
||||||
|
if (windowMgr.getMainWindow() && windowName === windowMgr.getMainWindow().winName) {
|
||||||
|
// reset the badge count whenever an user refreshes the electron client
|
||||||
|
badgeCount.show(0);
|
||||||
|
|
||||||
|
// Terminates the screen snippet process on reload
|
||||||
|
if (!isMac) {
|
||||||
|
eventEmitter.emit('killScreenSnippet');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle API related ipc messages from renderers. Only messages from windows
|
* Handle API related ipc messages from renderers. Only messages from windows
|
||||||
* we have created are allowed.
|
* we have created are allowed.
|
||||||
@@ -103,6 +123,10 @@ electron.ipcMain.on(apiName, (event, arg) => {
|
|||||||
if (arg.cmd === apiCmds.showNotificationSettings && typeof arg.windowName === 'string') {
|
if (arg.cmd === apiCmds.showNotificationSettings && typeof arg.windowName === 'string') {
|
||||||
configureNotification.openConfigurationWindow(arg.windowName);
|
configureNotification.openConfigurationWindow(arg.windowName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg.cmd === apiCmds.reload && typeof arg.windowName === 'string') {
|
||||||
|
reload(arg.windowName);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// expose these methods primarily for testing...
|
// expose these methods primarily for testing...
|
||||||
|
|||||||
@@ -367,17 +367,17 @@ function createAPI() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the badge count whenever an user refreshes the electron client
|
// Invoked whenever the app is reloaded/navigated
|
||||||
function resetBadgeCount() {
|
function reload() {
|
||||||
local.ipcRenderer.send(apiName, {
|
local.ipcRenderer.send(apiName, {
|
||||||
cmd: apiCmds.setBadgeCount,
|
cmd: apiCmds.reload,
|
||||||
count: 0
|
windowName: window.name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('offline', updateOnlineStatus, false);
|
window.addEventListener('offline', updateOnlineStatus, false);
|
||||||
window.addEventListener('online', updateOnlineStatus, false);
|
window.addEventListener('online', updateOnlineStatus, false);
|
||||||
window.addEventListener('beforeunload', resetBadgeCount, false);
|
window.addEventListener('beforeunload', reload, false);
|
||||||
|
|
||||||
updateOnlineStatus();
|
updateOnlineStatus();
|
||||||
}
|
}
|
||||||
@@ -181,6 +181,14 @@ function createWarn(msg) {
|
|||||||
}
|
}
|
||||||
/* eslint-enable class-methods-use-this */
|
/* eslint-enable class-methods-use-this */
|
||||||
|
|
||||||
|
// terminates the screen snippet process wherever the
|
||||||
|
// main window is reloaded/navigated
|
||||||
|
eventEmitter.on('killScreenSnippet', function () {
|
||||||
|
if (child) {
|
||||||
|
child.kill();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
ScreenSnippet: ScreenSnippet,
|
ScreenSnippet: ScreenSnippet,
|
||||||
// note: readResult only exposed for testing purposes
|
// note: readResult only exposed for testing purposes
|
||||||
|
|||||||
Reference in New Issue
Block a user