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<any>(loadDetailsPanel(collection.uuid));
- dispatch(collectionPanelActions.SET_COLLECTION(collection));
- dispatch(resourcesActions.SET_RESOURCES([collection]));
return collection;
};
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));