From ec5e4dbcc20656fe12373f40c2b54afd525ccd4f Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Sat, 10 Feb 2024 03:09:43 +0000 Subject: [PATCH] fix(mobile): stack entity handling (#6980) Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --- mobile/lib/shared/models/asset.dart | 16 +++++++++++----- server/src/immich/api-v1/asset/asset.service.ts | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mobile/lib/shared/models/asset.dart b/mobile/lib/shared/models/asset.dart index 0ed69dea75f53..10761616af9d1 100644 --- a/mobile/lib/shared/models/asset.dart +++ b/mobile/lib/shared/models/asset.dart @@ -34,7 +34,10 @@ class Asset { isTrashed = remote.isTrashed, isReadOnly = remote.isReadOnly, isOffline = remote.isOffline, - stackParentId = remote.stackParentId, + // workaround to nullify stackParentId for the parent asset until we refactor the mobile app + // stack handling to properly handle it + stackParentId = + remote.stackParentId == remote.id ? null : remote.stackParentId, stackCount = remote.stackCount; Asset.local(AssetEntity local, List hash) @@ -290,7 +293,6 @@ class Asset { width: a.width ?? width, height: a.height ?? height, exifInfo: a.exifInfo?.copyWith(id: id) ?? exifInfo, - stackCount: a.stackCount ?? stackCount, ); } else if (isRemote) { return _copyWith( @@ -305,7 +307,9 @@ class Asset { id: id, remoteId: remoteId, livePhotoVideoId: livePhotoVideoId, - stackParentId: stackParentId, + // workaround to nullify stackParentId for the parent asset until we refactor the mobile app + // stack handling to properly handle it + stackParentId: stackParentId == remoteId ? null : stackParentId, stackCount: stackCount, isFavorite: isFavorite, isArchived: isArchived, @@ -323,8 +327,10 @@ class Asset { width: a.width, height: a.height, livePhotoVideoId: a.livePhotoVideoId, - stackParentId: a.stackParentId, - stackCount: a.stackCount ?? stackCount, + // workaround to nullify stackParentId for the parent asset until we refactor the mobile app + // stack handling to properly handle it + stackParentId: a.stackParentId == a.remoteId ? null : a.stackParentId, + stackCount: a.stackCount, // isFavorite + isArchived are not set by device-only assets isFavorite: a.isFavorite, isArchived: a.isArchived, diff --git a/server/src/immich/api-v1/asset/asset.service.ts b/server/src/immich/api-v1/asset/asset.service.ts index 6a96bf531b4e2..b0ff311c51bcf 100644 --- a/server/src/immich/api-v1/asset/asset.service.ts +++ b/server/src/immich/api-v1/asset/asset.service.ts @@ -113,7 +113,7 @@ export class AssetService { const userId = dto.userId || auth.user.id; await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId); const assets = await this.assetRepositoryV1.getAllByUserId(userId, dto); - return assets.map((asset) => mapAsset(asset)); + return assets.map((asset) => mapAsset(asset, { withStack: true })); } async serveThumbnail(auth: AuthDto, assetId: string, dto: GetAssetThumbnailDto): Promise {