ELECTRON-591 - Add logic to close up child windows whenever parent window is navigated or reloaded (#446)

This commit is contained in:
Kiran Niranjan
2018-08-01 14:51:29 +05:30
committed by Vishwas Shashidhar
parent f893b5658c
commit 75d2e06673
5 changed files with 147 additions and 4 deletions

View File

@@ -1102,6 +1102,27 @@ function handleKeyPress(keyCode) {
}
}
/**
* Finds all the child window and closes it
*/
function cleanUpChildWindows() {
const browserWindows = BrowserWindow.getAllWindows();
notify.resetAnimationQueue();
if (browserWindows && browserWindows.length) {
browserWindows.forEach(browserWindow => {
// Closes only child windows
if (browserWindow && !browserWindow.isDestroyed() && browserWindow.winName !== 'main') {
// clean up notification windows
if (browserWindow.winName === 'notification-window') {
notify.closeAll();
} else {
browserWindow.close();
}
}
});
}
}
module.exports = {
createMainWindow: createMainWindow,
@@ -1115,5 +1136,6 @@ module.exports = {
verifyDisplays: verifyDisplays,
getMenu: getMenu,
setIsAutoReload: setIsAutoReload,
handleKeyPress: handleKeyPress
handleKeyPress: handleKeyPress,
cleanUpChildWindows: cleanUpChildWindows,
};