From ed049b13a4da7cb944ede3915fdb5dbce0a73e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erdi=20K=C3=B6se?= Date: Mon, 18 Oct 2021 01:19:34 +0300 Subject: [PATCH] fix: Always be sure to send actions to last focused window --- src/redux/main-store.ts | 10 +++++++++- src/redux/services/kubeConfigMonitor.ts | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/redux/main-store.ts b/src/redux/main-store.ts index 13221af471..2d7bee658b 100644 --- a/src/redux/main-store.ts +++ b/src/redux/main-store.ts @@ -9,6 +9,8 @@ import {alertSlice} from './reducers/alert'; import {logsSlice} from './reducers/logs'; import {uiSlice} from './reducers/ui'; +let lastFocusedWindow: BrowserWindow | null = null; + const forwardToRenderer = () => (next: any) => (action: any) => { if (!isFSA(action)) return next(action); if (action.meta && action.meta.scope === 'local') return next(action); @@ -21,7 +23,13 @@ const forwardToRenderer = () => (next: any) => (action: any) => { }, }; - BrowserWindow.getFocusedWindow()?.webContents.send('redux-action', rendererAction); + if (BrowserWindow.getFocusedWindow()) { + lastFocusedWindow = BrowserWindow.getFocusedWindow(); + } + + if (lastFocusedWindow) { + lastFocusedWindow.webContents.send('redux-action', rendererAction); + } return next(action); }; diff --git a/src/redux/services/kubeConfigMonitor.ts b/src/redux/services/kubeConfigMonitor.ts index 14c73919d1..163f50490e 100644 --- a/src/redux/services/kubeConfigMonitor.ts +++ b/src/redux/services/kubeConfigMonitor.ts @@ -14,7 +14,7 @@ export function monitorKubeConfig(filePath: string, dispatch: AppDispatch) { watcher = watch(filePath, { persistent: true, usePolling: true, - interval: 2000, + interval: 1000, }); watcher.on('all', () => {