diff --git a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts index d63e44fad..bd43281ba 100644 --- a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts +++ b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts @@ -308,12 +308,12 @@ export class PreprintStepperState { getProjectFilesByLink(ctx: StateContext, action: FetchProjectFilesByLink) { ctx.setState(patch({ projectFiles: patch({ isLoading: true }) })); - return this.fileService.getFilesWithoutFiltering(action.filesLink).pipe( - tap((files: FileModel[]) => { + return this.fileService.getFilesWithoutFiltering(action.filesLink, 1).pipe( + tap((response) => { ctx.setState( patch({ projectFiles: patch({ - data: files, + data: response.data, isLoading: false, }), }) diff --git a/src/app/features/registries/components/files-control/files-control.component.html b/src/app/features/registries/components/files-control/files-control.component.html index f2a233060..bf53c0a2f 100644 --- a/src/app/features/registries/components/files-control/files-control.component.html +++ b/src/app/features/registries/components/files-control/files-control.component.html @@ -46,6 +46,7 @@ [storage]="null" [currentFolder]="currentFolder()!" [isLoading]="isFilesLoading()" + [scrollHeight]="'500px'" [viewOnly]="filesViewOnly()" [resourceId]="projectId()" [provider]="provider()" diff --git a/src/app/features/registries/store/handlers/files.handlers.ts b/src/app/features/registries/store/handlers/files.handlers.ts index 478dd1e8e..e6b5d4f38 100644 --- a/src/app/features/registries/store/handlers/files.handlers.ts +++ b/src/app/features/registries/store/handlers/files.handlers.ts @@ -34,23 +34,27 @@ export class FilesHandlers { ); } - getProjectFiles(ctx: StateContext, { filesLink }: GetFiles) { + getProjectFiles(ctx: StateContext, { filesLink, page }: GetFiles) { const state = ctx.getState(); ctx.patchState({ files: { ...state.files, isLoading: true, + error: null, + totalCount: 0, }, }); - return this.filesService.getFilesWithoutFiltering(filesLink).pipe( + return this.filesService.getFilesWithoutFiltering(filesLink, page).pipe( tap((response) => { + const newData = page === 1 ? response.data : [...(state.files.data ?? []), ...response.data]; + ctx.patchState({ files: { - data: response, + data: newData, isLoading: false, error: null, - totalCount: response.length, + totalCount: response.totalCount, }, }); }), diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index 988adbcc1..0fd3306e0 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -16,6 +16,7 @@ import { OsfFileRevision, PatchFileMetadata, } from '@osf/features/files/models'; +import { PaginatedData } from '@osf/shared/models/paginated-data.model'; import { FileKind } from '../enums/file-kind.enum'; import { AddonMapper } from '../mappers/addon.mapper'; @@ -85,10 +86,17 @@ export class FilesService { .pipe(map((response) => ({ files: FilesMapper.getFileFolders(response.data), meta: response.meta }))); } - getFilesWithoutFiltering(filesLink: string): Observable { - return this.jsonApiService - .get(filesLink) - .pipe(map((response) => FilesMapper.getFiles(response.data))); + getFilesWithoutFiltering(filesLink: string, page = 1): Observable> { + const params: Record = { + page: page.toString(), + }; + return this.jsonApiService.get(filesLink, params).pipe( + map((response) => ({ + data: FilesMapper.getFiles(response.data), + totalCount: response.meta.total, + pageSize: response.meta.per_page, + })) + ); } uploadFile(