- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const files = await services.collectionService.files(uuid);
- dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES(files));
- dispatch(resourcesDataActions.SET_FILES({ uuid, files }));
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(progressIndicatorActions.START_WORKING(COLLECTION_PANEL_LOAD_FILES));
+ services.collectionService.files(uuid).then(files => {
+ // Given the array of directories and files, create the appropriate tree nodes,
+ // sort them, and add the complete url to each.
+ const tree = createCollectionFilesTree(files);
+ const sorted = sortFilesTree(tree);
+ const mapped = mapTreeValues(services.collectionService.extendFileURL)(sorted);
+ dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES(mapped));
+ dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PANEL_LOAD_FILES));
+ }).catch(() => {
+ dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PANEL_LOAD_FILES));
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: `Error getting file list`,
+ hideDuration: 2000,
+ kind: SnackbarKind.ERROR
+ }));
+ });