From c9dc3ce5cafdff639db4a1631d1d004bc153ddcf Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk <84377976+nikita-web-ua@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:06:27 +0100 Subject: [PATCH] [ACS-6583] fix flickering toolbar on folder upload (#3609) --- .../src/lib/components/files/files.component.spec.ts | 12 ++++++++++++ .../src/lib/components/files/files.component.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/projects/aca-content/src/lib/components/files/files.component.spec.ts b/projects/aca-content/src/lib/components/files/files.component.spec.ts index 3e53beb5d3..1121bf985a 100644 --- a/projects/aca-content/src/lib/components/files/files.component.spec.ts +++ b/projects/aca-content/src/lib/components/files/files.component.spec.ts @@ -227,6 +227,18 @@ describe('FilesComponent', () => { expect(component.reload).toHaveBeenCalled(); })); + it('should not call reload on fileUploadComplete event if file parent folder already displayed', fakeAsync(() => { + spyOn(component.documentList.data, 'getRows').and.returnValue([{ node: { entry: { isFolder: true, name: 'files' } } }] as any); + const file: any = { file: { options: { parentId: 'parentId', path: '/files' } } }; + component.node = { id: 'parentId' } as any; + + uploadService.fileUploadComplete.next(file); + + tick(500); + + expect(component.reload).not.toHaveBeenCalled(); + })); + it('should not call refresh on fileUploadComplete event if parent mismatch', fakeAsync(() => { const file: any = { file: { options: { parentId: 'otherId' } } }; component.node = { id: 'parentId' } as any; diff --git a/projects/aca-content/src/lib/components/files/files.component.ts b/projects/aca-content/src/lib/components/files/files.component.ts index 759e780c8e..7aba0fb979 100644 --- a/projects/aca-content/src/lib/components/files/files.component.ts +++ b/projects/aca-content/src/lib/components/files/files.component.ts @@ -257,7 +257,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { } displayFolderParent(index: number, filePath = '') { - const parentName = filePath.split('/')[index]; + const parentName = filePath.split('/').filter((el) => el)[index]; const currentFoldersDisplayed = (this.documentList.data.getRows() as ShareDataRow[]) || []; const alreadyDisplayedParentFolder = currentFoldersDisplayed.find((row) => row.node.entry.isFolder && row.node.entry.name === parentName);