feat: no small local thumbnail (#17787)

* feat: no small local thumbnail

* pr feedback
This commit is contained in:
Alex 2025-04-23 09:02:51 -05:00 committed by GitHub
parent 1de2eae12d
commit 13d6bd67b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,43 +42,34 @@ 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<ui.Codec> _codec(
Asset key,
Asset assetData,
ImageDecoderCallback decode,
StreamController<ImageChunkEvent> 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);
try {
final buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes);
final codec = await decode(buffer);
yield codec;
} finally {
chunkEvents.close();
}
}
@override
bool operator ==(Object other) {