From 8521ab13d523eed13754b861af34d07f40a8c442 Mon Sep 17 00:00:00 2001 From: Stephen Smith Date: Tue, 12 Nov 2024 10:43:26 -0500 Subject: [PATCH] 22000: Add flag to control writing nodes to favorites tree, eliminates flickering Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- .../src/store/favorites/favorites-actions.ts | 2 +- .../src/store/processes/processes-actions.ts | 2 +- .../public-favorites-actions.ts | 2 +- .../side-panel-tree-actions.ts | 48 +++++++++++-------- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/services/workbench2/src/store/favorites/favorites-actions.ts b/services/workbench2/src/store/favorites/favorites-actions.ts index 92658d9f32..98d2e71d58 100644 --- a/services/workbench2/src/store/favorites/favorites-actions.ts +++ b/services/workbench2/src/store/favorites/favorites-actions.ts @@ -56,7 +56,7 @@ export const toggleFavorite = (resource: { uuid: string; name: string }) => })); dispatch(removeDisabledButton(ContextMenuActionNames.ADD_TO_FAVORITES)) dispatch(progressIndicatorActions.STOP_WORKING("toggleFavorite")); - dispatch(loadFavoritesTree()) + dispatch(loadFavoritesTree(true)) }) .catch((e: any) => { dispatch(progressIndicatorActions.STOP_WORKING("toggleFavorite")); diff --git a/services/workbench2/src/store/processes/processes-actions.ts b/services/workbench2/src/store/processes/processes-actions.ts index 015b9470eb..f486fc0143 100644 --- a/services/workbench2/src/store/processes/processes-actions.ts +++ b/services/workbench2/src/store/processes/processes-actions.ts @@ -326,7 +326,7 @@ export const removeProcessPermanently = (uuid: string) => async (dispatch: Dispa } // Processes are deleted immediately, refresh favorites to remove any deleted favorites - dispatch(loadFavoritesTree()); + dispatch(loadFavoritesTree(true)); } // If currently viewing any of the deleted runs, navigate to home diff --git a/services/workbench2/src/store/public-favorites/public-favorites-actions.ts b/services/workbench2/src/store/public-favorites/public-favorites-actions.ts index b9915dbdf1..6fcd737a65 100644 --- a/services/workbench2/src/store/public-favorites/public-favorites-actions.ts +++ b/services/workbench2/src/store/public-favorites/public-favorites-actions.ts @@ -53,7 +53,7 @@ export const togglePublicFavorite = (resource: { uuid: string; name: string }) = })); dispatch(removeDisabledButton(ContextMenuActionNames.ADD_TO_PUBLIC_FAVORITES)) dispatch(progressIndicatorActions.STOP_WORKING("togglePublicFavorite")); - dispatch(loadPublicFavoritesTree()) + dispatch(loadPublicFavoritesTree(true)) }) .catch((e: any) => { dispatch(progressIndicatorActions.STOP_WORKING("togglePublicFavorite")); diff --git a/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts b/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts index 8c8f5d0632..954a064baf 100644 --- a/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts +++ b/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts @@ -102,10 +102,10 @@ export const loadSidePanelTreeProjects = (projectUuid: string) => const treePicker = getTreePicker(SIDE_PANEL_TREE)(getState().treePicker); const node = treePicker ? getNode(projectUuid)(treePicker) : undefined; if (projectUuid === SidePanelTreeCategory.PUBLIC_FAVORITES) { - const unverifiedPubFaves = await dispatch(loadPublicFavoritesTree()); + const unverifiedPubFaves = await dispatch(loadPublicFavoritesTree(false)); verifyAndUpdateLinkNames(projectUuid, unverifiedPubFaves, dispatch, getState, services); } else if (projectUuid === SidePanelTreeCategory.FAVORITES) { - const unverifiedFaves = await dispatch(loadFavoritesTree()); + const unverifiedFaves = await dispatch(loadFavoritesTree(false)); await setFaves(unverifiedFaves, dispatch, getState, services); verifyAndUpdateLinkNames(projectUuid, unverifiedFaves, dispatch, getState, services); } else if (node || projectUuid !== '') { @@ -142,8 +142,10 @@ const loadProject = (projectUuid: string) => dispatch(resourcesActions.SET_RESOURCES(items)); }; -export const loadFavoritesTree = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.FAVORITES, pickerId: SIDE_PANEL_TREE })); +export const loadFavoritesTree = (updateTree: boolean) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + if (updateTree) { + dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.FAVORITES, pickerId: SIDE_PANEL_TREE })); + } const params = { filters: new FilterBuilder() @@ -157,13 +159,15 @@ export const loadFavoritesTree = () => async (dispatch: Dispatch, getState: () = const { items } = await services.linkService.list(params); - dispatch( - treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ - id: SidePanelTreeCategory.FAVORITES, - pickerId: SIDE_PANEL_TREE, - nodes: items.map(item => initTreeNode({ id: item.headUuid, value: item.name })), - }) - ); + if (updateTree) { + dispatch( + treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ + id: SidePanelTreeCategory.FAVORITES, + pickerId: SIDE_PANEL_TREE, + nodes: items.map(item => initTreeNode({ id: item.headUuid, value: item.name })), + }) + ); + } return items; }; @@ -207,8 +211,10 @@ const verifyAndUpdateLinkNames = async (category: SidePanelTreeCategory, links: ); }; -export const loadPublicFavoritesTree = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.PUBLIC_FAVORITES, pickerId: SIDE_PANEL_TREE })); +export const loadPublicFavoritesTree = (updateTree: boolean) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + if (updateTree) { + dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.PUBLIC_FAVORITES, pickerId: SIDE_PANEL_TREE })); + } const uuidPrefix = getState().auth.config.uuidPrefix; const publicProjectUuid = `${uuidPrefix}-j7d0g-publicfavorites`; @@ -252,13 +258,15 @@ export const loadPublicFavoritesTree = () => async (dispatch: Dispatch, getState const filteredItems = items.filter(item => responseItems.some(responseItem => responseItem.uuid === item.headUuid)); - dispatch( - treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ - id: SidePanelTreeCategory.PUBLIC_FAVORITES, - pickerId: SIDE_PANEL_TREE, - nodes: filteredItems.map(item => initTreeNode({ id: item.headUuid, value: item })), - }) - ); + if (updateTree) { + dispatch( + treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ + id: SidePanelTreeCategory.PUBLIC_FAVORITES, + pickerId: SIDE_PANEL_TREE, + nodes: filteredItems.map(item => initTreeNode({ id: item.headUuid, value: item })), + }) + ); + } //setting resources here so they won't be re-fetched in validation step dispatch(resourcesActions.SET_RESOURCES(responseItems)); -- 2.30.2