From e42cf4ce21b12c1a1ddfdb13d99e9dc9c56a6616 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Mon, 10 Nov 2025 22:28:45 +0100 Subject: [PATCH] Fix contentwrapper packing and unpacking issue --- src/backend/middlewares/GalleryMWs.ts | 2 +- src/common/entities/ContentWrapper.ts | 10 ++++++++-- src/frontend/app/ui/gallery/contentLoader.service.ts | 11 +++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/backend/middlewares/GalleryMWs.ts b/src/backend/middlewares/GalleryMWs.ts index 85042b58..b3248d16 100644 --- a/src/backend/middlewares/GalleryMWs.ts +++ b/src/backend/middlewares/GalleryMWs.ts @@ -220,7 +220,7 @@ export class GalleryMWs { } } - ContentWrapperUtils.pack(cw); + req.resultPipe = ContentWrapperUtils.pack(cw); return next(); } diff --git a/src/common/entities/ContentWrapper.ts b/src/common/entities/ContentWrapper.ts index 37043009..dbb61db8 100644 --- a/src/common/entities/ContentWrapper.ts +++ b/src/common/entities/ContentWrapper.ts @@ -64,7 +64,13 @@ export class ContentWrapperUtils { } const c1 = cw1.directory || cw1.searchResult; const c2 = cw2.directory || cw2.searchResult; + if (c1 === c2) { + return true; + } + if (!c1 || !c2) { + return false; + } if (!this.equalsDirectories(c1.directories, c2.directories)) { return false; } @@ -181,7 +187,6 @@ export class ContentWrapperUtils { static pack(cwIn: ContentWrapper): PackedContentWrapper { const cw: PackedContentWrapper = { - ...cwIn, map: { faces: [], keywords: [], lens: [], camera: [], directories: [] @@ -189,7 +194,8 @@ export class ContentWrapperUtils { reverseMap: { faces: new Map(), keywords: new Map(), lens: new Map(), camera: new Map(), directories: new Map() - } + }, + ...cwIn }; if (cw?.directory) { diff --git a/src/frontend/app/ui/gallery/contentLoader.service.ts b/src/frontend/app/ui/gallery/contentLoader.service.ts index 37b75b67..74e2d800 100644 --- a/src/frontend/app/ui/gallery/contentLoader.service.ts +++ b/src/frontend/app/ui/gallery/contentLoader.service.ts @@ -57,8 +57,7 @@ export class ContentLoaderService { // load from cache const cw = this.galleryCacheService.getDirectory(directoryName); - ContentWrapperUtils.unpack(cw); - this.setContent(cw); + this.setContent( ContentWrapperUtils.unpack(cw)); this.lastRequest.directory = directoryName; this.currentContentRequest = {type: 'directory', value: directoryName}; @@ -99,10 +98,7 @@ export class ContentLoaderService { if (this.lastRequest.directory !== directoryName) { return; } - - ContentWrapperUtils.unpack(cw); - - this.setContent(cw); + this.setContent(ContentWrapperUtils.unpack(cw)); } catch (e) { console.error(e); this.navigationService.toGallery().catch(console.error); @@ -140,8 +136,7 @@ export class ContentLoaderService { return; } - ContentWrapperUtils.unpack(cw); - this.setContent(cw); + this.setContent(ContentWrapperUtils.unpack(cw)); } isSearchResult(): boolean {