Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): cache key for assets from dto (#4699)

shenlong512f672e9e3d
diff --git a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart
index 01df0e6857..d62e636494 100644
--- a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart
+++ b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart
@@ -90,7 +90,7 @@ class GalleryViewerPage extends HookConsumerWidget {
: <Asset>[];
final stackElements = showStack ? [currentAsset, ...stack] : <Asset>[];
// Assets from response DTOs do not have an isar id, querying which would give us the default autoIncrement id
- final isFromResponse = currentAsset.id == Isar.autoIncrement;
+ final isFromDto = currentAsset.id == Isar.autoIncrement;
Asset asset() => stackIndex.value == -1
? currentAsset
@@ -773,7 +773,7 @@ class GalleryViewerPage extends HookConsumerWidget {
},
imageProvider: provider,
heroAttributes: PhotoViewHeroAttributes(
- tag: isFromResponse
+ tag: isFromDto
? '${a.remoteId}-$heroOffset'
: a.id + heroOffset,
),
@@ -792,7 +792,7 @@ class GalleryViewerPage extends HookConsumerWidget {
onDragUpdate: (_, details, __) =>
handleSwipeUpDown(details),
heroAttributes: PhotoViewHeroAttributes(
- tag: isFromResponse
+ tag: isFromDto
? '${a.remoteId}-$heroOffset'
: a.id + heroOffset,
),
diff --git a/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart b/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart
index 4383fe332c..2450e44393 100644
--- a/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart
+++ b/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart
@@ -45,7 +45,7 @@ class ThumbnailImage extends StatelessWidget {
final assetContainerColor =
isDarkTheme ? Colors.blueGrey : Theme.of(context).primaryColorLight;
// Assets from response DTOs do not have an isar id, querying which would give us the default autoIncrement id
- final isFromResponse = asset.id == Isar.autoIncrement;
+ final isFromDto = asset.id == Isar.autoIncrement;
Widget buildSelectionIcon(Asset asset) {
if (isSelected) {
@@ -134,7 +134,7 @@ class ThumbnailImage extends StatelessWidget {
width: 300,
height: 300,
child: Hero(
- tag: isFromResponse
+ tag: isFromDto
? '${asset.remoteId}-$heroOffset'
: asset.id + heroOffset,
child: ImmichImage(
diff --git a/mobile/lib/utils/image_url_builder.dart b/mobile/lib/utils/image_url_builder.dart
index 2056237cbd..6fef55c2f7 100644
--- a/mobile/lib/utils/image_url_builder.dart
+++ b/mobile/lib/utils/image_url_builder.dart
@@ -1,6 +1,7 @@
import 'package:immich_mobile/shared/models/album.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/models/store.dart';
+import 'package:isar/isar.dart';
import 'package:openapi/api.dart';
String getThumbnailUrl(
@@ -35,8 +36,10 @@ String getAlbumThumbnailUrl(
if (album.thumbnail.value?.remoteId == null) {
return '';
}
- return getThumbnailUrlForRemoteId(album.thumbnail.value!.remoteId!,
- type: type,);
+ return getThumbnailUrlForRemoteId(
+ album.thumbnail.value!.remoteId!,
+ type: type,
+ );
}
String getAlbumThumbNailCacheKey(
@@ -57,7 +60,9 @@ String getImageUrl(final Asset asset) {
}
String getImageCacheKey(final Asset asset) {
- return '${asset.id}_fullStage';
+ // Assets from response DTOs do not have an isar id, querying which would give us the default autoIncrement id
+ final isFromDto = asset.id == Isar.autoIncrement;
+ return '${isFromDto ? asset.remoteId : asset.id}_fullStage';
}
String getThumbnailUrlForRemoteId(