refs #13828 Merge branch 'origin/13828-trash-view'
[arvados-workbench2.git] / src / index.tsx
index 6137e26dd9319e83d4973280c8dab04b9e209e1d..4ce80d31e9d0f0360e6dd7051b113f9dbfe4d40c 100644 (file)
@@ -32,6 +32,9 @@ import { addRouteChangeHandlers } from './routes/routes';
 import { loadWorkbench } from './store/workbench/workbench-actions';
 import { Routes } from '~/routes/routes';
 import { trashActionSet } from "~/views-components/context-menu/action-sets/trash-action-set";
+import { ServiceRepository } from '~/services/services';
+import { initWebSocket } from '~/websocket/websocket';
+import { Config } from '~/common/config';
 
 const getBuildNumber = () => "BN-" + (process.env.REACT_APP_BUILD_NUMBER || "dev");
 const getGitCommit = () => "GIT-" + (process.env.REACT_APP_GIT_COMMIT || "latest").substr(0, 7);
@@ -58,8 +61,7 @@ fetchConfig()
         const services = createServices(config);
         const store = configureStore(history, services);
 
-        store.subscribe(initListener(history, store));
-
+        store.subscribe(initListener(history, store, services, config));
         store.dispatch(initAuth());
 
         const TokenComponent = (props: any) => <ApiToken authService={services.authService} {...props} />;
@@ -85,12 +87,13 @@ fetchConfig()
 
     });
 
-const initListener = (history: History, store: RootStore) => {
+const initListener = (history: History, store: RootStore, services: ServiceRepository, config: Config) => {
     let initialized = false;
     return async () => {
         const { router, auth } = store.getState();
         if (router.location && auth.user && !initialized) {
             initialized = true;
+            initWebSocket(config, services.authService, store);
             await store.dispatch(loadWorkbench());
             addRouteChangeHandlers(history, store);
         }