From 2beaffc9ab6cf7213b97765cb7485ffdffc9dbf7 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 29 Dec 2022 09:38:11 +0100 Subject: [PATCH] fix(App): update ctx api actions hook logic --- src/App/App.js | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/App/App.js b/src/App/App.js index 124e4f53d..1735cee0d 100644 --- a/src/App/App.js +++ b/src/App/App.js @@ -91,28 +91,29 @@ const App = () => { }, []); React.useEffect(() => { const onWindowFocus = () => { - if (services.core.active) { - services.core.transport.dispatch({ - action: 'Ctx', - args: { - action: 'PullAddonsFromAPI' - } - }); - services.core.transport.dispatch({ - action: 'Ctx', - args: { - action: 'PullUserFromAPI' - } - }); - services.core.transport.dispatch({ - action: 'Ctx', - args: { - action: 'SyncLibraryWithAPI' - } - }); - } + services.core.transport.dispatch({ + action: 'Ctx', + args: { + action: 'PullAddonsFromAPI' + } + }); + services.core.transport.dispatch({ + action: 'Ctx', + args: { + action: 'PullUserFromAPI' + } + }); + services.core.transport.dispatch({ + action: 'Ctx', + args: { + action: 'SyncLibraryWithAPI' + } + }); }; - window.addEventListener('focus', onWindowFocus); + if (services.core.active) { + onWindowFocus(); + window.addEventListener('focus', onWindowFocus); + } return () => window.removeEventListener('focus', onWindowFocus); }, [initialized]); return (