Skip to content

Commit

Permalink
fix: Always be sure to send actions to last focused window
Browse files Browse the repository at this point in the history
  • Loading branch information
erdkse committed Oct 17, 2021
1 parent b721c64 commit ed049b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/redux/main-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
};
Expand Down
2 changes: 1 addition & 1 deletion src/redux/services/kubeConfigMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit ed049b1

Please sign in to comment.