From 13d6bd67b163b9fd58b8cc0129eb14ee397e5cdc Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 23 Apr 2025 09:02:51 -0500 Subject: [PATCH] feat: no small local thumbnail (#17787) * feat: no small local thumbnail * pr feedback --- .../immich_local_thumbnail_provider.dart | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/mobile/lib/providers/image/immich_local_thumbnail_provider.dart b/mobile/lib/providers/image/immich_local_thumbnail_provider.dart index 54dfd97983..1e2f5d312e 100644 --- a/mobile/lib/providers/image/immich_local_thumbnail_provider.dart +++ b/mobile/lib/providers/image/immich_local_thumbnail_provider.dart @@ -42,42 +42,33 @@ class ImmichLocalThumbnailProvider scale: 1.0, chunkEvents: chunkEvents.stream, informationCollector: () sync* { - yield ErrorDescription(asset.fileName); + yield ErrorDescription(key.asset.fileName); }, ); } // Streams in each stage of the image as we ask for it Stream _codec( - Asset key, + Asset assetData, ImageDecoderCallback decode, StreamController chunkEvents, ) async* { - // Load a small thumbnail - final thumbBytes = await asset.local?.thumbnailDataWithSize( - const ThumbnailSize.square(32), - quality: 75, - ); - if (thumbBytes != null) { - final buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes); - final codec = await decode(buffer); - yield codec; - } else { - debugPrint("Loading thumb for ${asset.fileName} failed"); - } - - final normalThumbBytes = - await asset.local?.thumbnailDataWithSize(ThumbnailSize(width, height)); - if (normalThumbBytes == null) { + final thumbBytes = await assetData.local + ?.thumbnailDataWithSize(ThumbnailSize(width, height)); + if (thumbBytes == null) { + chunkEvents.close(); throw StateError( "Loading thumb for local photo ${asset.fileName} failed", ); } - final buffer = await ui.ImmutableBuffer.fromUint8List(normalThumbBytes); - final codec = await decode(buffer); - yield codec; - chunkEvents.close(); + try { + final buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes); + final codec = await decode(buffer); + yield codec; + } finally { + chunkEvents.close(); + } } @override