Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Prevent error when two BrowserWindow events collide; Reduce window flashing #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ module.exports = function (config, windowParams) {
const authWindow = new BrowserWindow(windowParams || {'use-content-size': true});

authWindow.loadURL(url);
authWindow.show();
authWindow.once('ready-to-show', () => {
authWindow.show();
});


authWindow.on('closed', () => {
reject(new Error('window was closed by user'));
Expand All @@ -64,13 +67,17 @@ module.exports = function (config, windowParams) {
reject(error);
authWindow.removeAllListeners('closed');
setImmediate(function () {
authWindow.close();
if(!authWindow.isDestroyed()){
authWindow.close();
}
});
} else if (code) {
resolve(code);
authWindow.removeAllListeners('closed');
setImmediate(function () {
authWindow.close();
if(!authWindow.isDestroyed()){
authWindow.close();
}
});
}
}
Expand Down