From a5b33e907ee914b5f934f3a90fd2a0a292668b62 Mon Sep 17 00:00:00 2001 From: Alrik Wendel <31699427+Awendel@users.noreply.github.com> Date: Tue, 13 Sep 2022 18:41:03 +0200 Subject: [PATCH 1/3] fixed reload issue --- src/hook.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hook.js b/src/hook.js index af7ae04..394c57b 100644 --- a/src/hook.js +++ b/src/hook.js @@ -25,11 +25,16 @@ function reload() { if (windows && windows.length) { for (const win of windows) { - win.webContents.reloadIgnoringCache(); + win.webContents.reloadIgnoringCache() + + const views = win.getBrowserViews() + views.forEach(function(view){ + view.webContents.reloadIgnoringCache() + }) + } } } - required.on('file', ({ type, id }) => { if (type !== 'file') { return; From 49aaf9dbad31eb607fa3c2589069c018cd11443e Mon Sep 17 00:00:00 2001 From: Alrik Wendel <31699427+Awendel@users.noreply.github.com> Date: Wed, 14 Sep 2022 17:02:00 +0200 Subject: [PATCH 2/3] changed it to watch parentFolder as root to access sibling changes --- src/electronmon.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/electronmon.js b/src/electronmon.js index 3e25a34..8e536be 100644 --- a/src/electronmon.js +++ b/src/electronmon.js @@ -161,7 +161,8 @@ module.exports = ({ function startWatcher() { return new Promise((resolve) => { - const watcher = watch({ root: cwd, patterns }); + const parentFolder = cwd.replace("\\Host","") + const watcher = watch({ root: parentFolder, patterns }); globalWatcher = watcher; watcher.on('change', ({ path: fullpath }) => { From dce73edb848118299f2317288089c15f089830b7 Mon Sep 17 00:00:00 2001 From: Alrik Wendel <31699427+Awendel@users.noreply.github.com> Date: Sat, 17 Sep 2022 19:52:49 +0200 Subject: [PATCH 3/3] check if win / webContent destroyed before reloading --- src/hook.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hook.js b/src/hook.js index 394c57b..dc45e30 100644 --- a/src/hook.js +++ b/src/hook.js @@ -25,12 +25,16 @@ function reload() { if (windows && windows.length) { for (const win of windows) { - win.webContents.reloadIgnoringCache() + if(win.isDestroyed() == false){ + win.webContents.reloadIgnoringCache() - const views = win.getBrowserViews() - views.forEach(function(view){ - view.webContents.reloadIgnoringCache() - }) + const views = win.getBrowserViews() + views.forEach(function(view){ + if(view.webContents.isDestroyed() == false){ + view.webContents.reloadIgnoringCache() + } + }) + } } }