From 05010c44073b52c0e414d180cfc21bae215c4d33 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 31 May 2022 09:19:10 -0300 Subject: [PATCH] 18787: Avoids re-rendering by only dispatching SET_COLLECTIONS when needed. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../collection-panel/collection-panel-action.ts | 13 ++++++++----- src/store/workbench/workbench-actions.ts | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts index 890a7441..7bab8632 100644 --- a/src/store/collection-panel/collection-panel-action.ts +++ b/src/store/collection-panel/collection-panel-action.ts @@ -22,12 +22,15 @@ export type CollectionPanelAction = UnionOf; export const loadCollectionPanel = (uuid: string, forceReload = false) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const { collectionPanel: { item } } = getState(); - const collection = (item && item.uuid === uuid && !forceReload) - ? item - : await services.collectionService.get(uuid); + let collection: CollectionResource | null = null; + if (!item || item.uuid !== uuid || forceReload) { + collection = await services.collectionService.get(uuid); + dispatch(collectionPanelActions.SET_COLLECTION(collection)); + dispatch(resourcesActions.SET_RESOURCES([collection])); + } else { + collection = item; + } dispatch(loadDetailsPanel(collection.uuid)); - dispatch(collectionPanelActions.SET_COLLECTION(collection)); - dispatch(resourcesActions.SET_RESOURCES([collection])); return collection; }; diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts index 3142b633..0a348431 100644 --- a/src/store/workbench/workbench-actions.ts +++ b/src/store/workbench/workbench-actions.ts @@ -295,7 +295,7 @@ export const loadCollection = (uuid: string) => if (userUuid) { const match = await loadGroupContentsResource({ uuid, userUuid, services }); match({ - OWNED: async collection => { + OWNED: collection => { dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource)); dispatch(updateResources([collection])); dispatch(activateSidePanelTreeItem(collection.ownerUuid)); -- 2.30.2