1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-04 02:46:47 +01:00

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

Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2023-10-29 20:28:54 +00:00 committed by GitHub
parent b117985f66
commit 512f672e9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View file

@ -90,7 +90,7 @@ class GalleryViewerPage extends HookConsumerWidget {
: <Asset>[]; : <Asset>[];
final stackElements = showStack ? [currentAsset, ...stack] : <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 // 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 Asset asset() => stackIndex.value == -1
? currentAsset ? currentAsset
@ -773,7 +773,7 @@ class GalleryViewerPage extends HookConsumerWidget {
}, },
imageProvider: provider, imageProvider: provider,
heroAttributes: PhotoViewHeroAttributes( heroAttributes: PhotoViewHeroAttributes(
tag: isFromResponse tag: isFromDto
? '${a.remoteId}-$heroOffset' ? '${a.remoteId}-$heroOffset'
: a.id + heroOffset, : a.id + heroOffset,
), ),
@ -792,7 +792,7 @@ class GalleryViewerPage extends HookConsumerWidget {
onDragUpdate: (_, details, __) => onDragUpdate: (_, details, __) =>
handleSwipeUpDown(details), handleSwipeUpDown(details),
heroAttributes: PhotoViewHeroAttributes( heroAttributes: PhotoViewHeroAttributes(
tag: isFromResponse tag: isFromDto
? '${a.remoteId}-$heroOffset' ? '${a.remoteId}-$heroOffset'
: a.id + heroOffset, : a.id + heroOffset,
), ),

View file

@ -45,7 +45,7 @@ class ThumbnailImage extends StatelessWidget {
final assetContainerColor = final assetContainerColor =
isDarkTheme ? Colors.blueGrey : Theme.of(context).primaryColorLight; 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 // 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) { Widget buildSelectionIcon(Asset asset) {
if (isSelected) { if (isSelected) {
@ -134,7 +134,7 @@ class ThumbnailImage extends StatelessWidget {
width: 300, width: 300,
height: 300, height: 300,
child: Hero( child: Hero(
tag: isFromResponse tag: isFromDto
? '${asset.remoteId}-$heroOffset' ? '${asset.remoteId}-$heroOffset'
: asset.id + heroOffset, : asset.id + heroOffset,
child: ImmichImage( child: ImmichImage(

View file

@ -1,6 +1,7 @@
import 'package:immich_mobile/shared/models/album.dart'; import 'package:immich_mobile/shared/models/album.dart';
import 'package:immich_mobile/shared/models/asset.dart'; import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/models/store.dart'; import 'package:immich_mobile/shared/models/store.dart';
import 'package:isar/isar.dart';
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
String getThumbnailUrl( String getThumbnailUrl(
@ -35,8 +36,10 @@ String getAlbumThumbnailUrl(
if (album.thumbnail.value?.remoteId == null) { if (album.thumbnail.value?.remoteId == null) {
return ''; return '';
} }
return getThumbnailUrlForRemoteId(album.thumbnail.value!.remoteId!, return getThumbnailUrlForRemoteId(
type: type,); album.thumbnail.value!.remoteId!,
type: type,
);
} }
String getAlbumThumbNailCacheKey( String getAlbumThumbNailCacheKey(
@ -57,7 +60,9 @@ String getImageUrl(final Asset asset) {
} }
String getImageCacheKey(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( String getThumbnailUrlForRemoteId(