From 8e265d5c977f1f7bfbb3854efb83ac417224e9fe Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Sat, 23 Jan 2021 14:37:47 +0000 Subject: [PATCH] Fix clicking cancel exits app (#67) * fix: clicking cancel exits app * chore: fix formatting --- lib/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5d84611..5abebc0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -68,6 +68,10 @@ function electronPrompt(options, parentWindow) { }; const cleanup = () => { + ipcMain.removeListener('prompt-get-options:' + id, getOptionsListener); + ipcMain.removeListener('prompt-post-data:' + id, postDataListener); + ipcMain.removeListener('prompt-error:' + id, errorListener); + if (promptWindow) { promptWindow.close(); promptWindow = null; @@ -97,9 +101,8 @@ function electronPrompt(options, parentWindow) { promptWindow.on('unresponsive', unresponsiveListener); promptWindow.on('closed', () => { - ipcMain.removeListener('prompt-get-options:' + id, getOptionsListener); - ipcMain.removeListener('prompt-post-data:' + id, postDataListener); - ipcMain.removeListener('prompt-error:' + id, postDataListener); + promptWindow = null; + cleanup(); resolve(null); });