From c1a93c0a9281bcd4e3757042a6f2dfb4517ea3bd Mon Sep 17 00:00:00 2001 From: Paul Tiedtke Date: Tue, 27 Oct 2020 10:04:40 +0100 Subject: [PATCH] feat: ignore devtools when sending actions to renderers (#275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maciej MaƂkowski --- src/mainStateSyncEnhancer.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mainStateSyncEnhancer.ts b/src/mainStateSyncEnhancer.ts index 64837679..c25b41a8 100644 --- a/src/mainStateSyncEnhancer.ts +++ b/src/mainStateSyncEnhancer.ts @@ -17,8 +17,11 @@ function createMiddleware(options: MainStateSyncEnhancerOptions) { // Forward it to all of the other renderers webContents.getAllWebContents().forEach((contents) => { - // Ignore the renderer that sent the action - if (contents.id !== event.sender.id) { + // Ignore the renderer that sent the action and chromium devtools + if ( + contents.id !== event.sender.id && + !contents.getURL().startsWith('devtools://') + ) { contents.send('electron-redux.ACTION', localAction) } }) @@ -27,6 +30,8 @@ function createMiddleware(options: MainStateSyncEnhancerOptions) { return (next) => (action) => { if (validateAction(action)) { webContents.getAllWebContents().forEach((contents) => { + // Ignore chromium devtools + if (contents.getURL().startsWith('devtools://')) return contents.send('electron-redux.ACTION', action) }) }