- let collection: CollectionResource | null = null;
-
- if (extractUuidKind(uuid) === ResourceKind.COLLECTION) {
- /**
- * Use of /group/contents API is the only way to get trashed item
- * A get method of a service will throw an exception with 404 status for resources that are trashed
- */
- const resource = await loadGroupContentsResource(uuid, userUuid, services);
- if (resource) {
- if (resource.kind === ResourceKind.COLLECTION) {
- collection = resource;
- if (collection.isTrashed) {
- dispatch(setTrashBreadcrumbs(''));
- dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
- } else {
- await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
- dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
- }
- }
- } else {
- /**
- * If item is not accesible using loadGroupContentsResource,
- * but it can be obtained using the get method of the service
- * then it is shared with the user
- */
- collection = await services.collectionService.get(uuid);
- if (collection) {
- dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
- dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
- }
- }
- if (collection) {
+ const match = await loadGroupContentsResource({ uuid, userUuid, services });
+ match({
+ OWNED: async collection => {
+ dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));