From 2691653274219da6c63665a18c9efdaf19d67ce5 Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 5 Nov 2021 21:31:31 +0100 Subject: [PATCH] Improve performance by comparing file ids instead of hashes Signed-off-by: trivernis --- .../src/app/components/file-gallery/file-gallery.component.ts | 2 +- .../files-tab/files-tab-sidebar/files-tab-sidebar.component.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mediarepo-ui/src/app/components/file-gallery/file-gallery.component.ts b/mediarepo-ui/src/app/components/file-gallery/file-gallery.component.ts index 4f31eeb..942496e 100644 --- a/mediarepo-ui/src/app/components/file-gallery/file-gallery.component.ts +++ b/mediarepo-ui/src/app/components/file-gallery/file-gallery.component.ts @@ -173,7 +173,7 @@ export class FileGalleryComponent implements OnChanges, OnInit { private getPreselectedEntry(): Selectable | undefined { if (this.preselectedFile) { const entry = this.entries.find( - e => e.data.hash == this.preselectedFile?.hash); + e => e.data.id === this.preselectedFile?.id); if (entry) { return entry; } diff --git a/mediarepo-ui/src/app/pages/home/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts b/mediarepo-ui/src/app/pages/home/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts index 37d69f5..96d0b7c 100644 --- a/mediarepo-ui/src/app/pages/home/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts +++ b/mediarepo-ui/src/app/pages/home/files-tab/files-tab-sidebar/files-tab-sidebar.component.ts @@ -78,7 +78,7 @@ export class FilesTabSidebarComponent implements OnInit, OnChanges { private async refreshFileSelection() { const filteredSelection = this.selectedFiles.filter( - file => this.files.findIndex(f => f.hash === file.hash) >= 0); + file => this.files.findIndex(f => f.id === file.id) >= 0); if (filteredSelection.length === 0) { this.tags = []; this.showAllTagsFallback(); @@ -93,7 +93,6 @@ export class FilesTabSidebarComponent implements OnInit, OnChanges { this.tags = this.tagsOfFiles.sort( (a, b) => a.getNormalizedOutput() .localeCompare(b.getNormalizedOutput())); - ; } } }