Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mobile): stack entity handling #6980

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions mobile/lib/shared/models/asset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> hash)
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion server/src/immich/api-v1/asset/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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<ImmichFileResponse> {
Expand Down
Loading