18787: Removes unnecessary store init to avoid forced refreshes.
[arvados-workbench2.git] / src / store / project-tree-picker / project-tree-picker-actions.ts
index 31110175412f32c8dc1363677a223c60e2306e2b..2e980738787fdc5232f6213c6908e10d3df78eaf 100644 (file)
@@ -3,23 +3,24 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { Dispatch } from "redux";
-import { RootState } from "~/store/store";
-import { ServiceRepository } from "~/services/services";
-import { mockProjectResource } from "~/models/test-utils";
-import { treePickerActions, receiveTreePickerProjectsData } from "~/store/tree-picker/tree-picker-actions";
-import { TreePickerId } from '~/models/tree';
+import { RootState } from "store/store";
+import { getUserUuid } from "common/getuser";
+import { ServiceRepository } from "services/services";
+import { mockProjectResource } from "models/test-utils";
+import { treePickerActions, receiveTreePickerProjectsData } from "store/tree-picker/tree-picker-actions";
+import { TreePickerId } from 'models/tree';
 
 export const resetPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.PROJECTS}));
-    dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.SHARED_WITH_ME}));
-    dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.FAVORITES}));
+    dispatch<any>(treePickerActions.RESET_TREE_PICKER({ pickerId: TreePickerId.PROJECTS }));
+    dispatch<any>(treePickerActions.RESET_TREE_PICKER({ pickerId: TreePickerId.SHARED_WITH_ME }));
+    dispatch<any>(treePickerActions.RESET_TREE_PICKER({ pickerId: TreePickerId.FAVORITES }));
 
     dispatch<any>(initPickerProjectTree());
 };
 
 export const initPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    const uuid = services.authService.getUuid();
-
+    const uuid = getUserUuid(getState());
+    if (!uuid) { return; }
     dispatch<any>(getPickerTreeProjects(uuid));
     dispatch<any>(getSharedWithMeProjectsPickerTree(uuid));
     dispatch<any>(getFavoritesProjectsPickerTree(uuid));
@@ -43,4 +44,4 @@ const getProjectsPickerTree = (uuid: string, kind: string) => {
         [mockProjectResource({ uuid, name: kind })],
         kind
     );
-};
\ No newline at end of file
+};