1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

feat(mobile): faster image loader (#8140)

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Fynn Petersen-Frey 2024-03-21 17:51:03 +01:00 committed by GitHub
parent 5ef6215546
commit 1abb0bdae8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,8 +16,6 @@ class ImageLoader {
required ImageCacheManager cache,
required ImageDecoderCallback decode,
StreamController<ImageChunkEvent>? chunkEvents,
int? height,
int? width,
}) async {
final headers = {
'x-immich-user-token': Store.get(StoreKey.accessToken),
@ -25,10 +23,8 @@ class ImageLoader {
final stream = cache.getImageFile(
uri,
withProgress: true,
withProgress: chunkEvents != null,
headers: headers,
maxHeight: height,
maxWidth: width,
);
await for (final result in stream) {
@ -40,13 +36,9 @@ class ImageLoader {
expectedTotalBytes: result.totalSize,
),
);
}
if (result is FileInfo) {
} else if (result is FileInfo) {
// We have the file
final file = result.file;
final bytes = await file.readAsBytes();
final buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
final buffer = await ui.ImmutableBuffer.fromFilePath(result.file.path);
final decoded = await decode(buffer);
return decoded;
}