From 1abb0bdae830401bd510953fa3952a3e65f9a840 Mon Sep 17 00:00:00 2001 From: Fynn Petersen-Frey <10599762+fyfrey@users.noreply.github.com> Date: Thu, 21 Mar 2024 17:51:03 +0100 Subject: [PATCH] feat(mobile): faster image loader (#8140) Co-authored-by: Alex Tran --- .../image_providers/cache/image_loader.dart | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mobile/lib/modules/asset_viewer/image_providers/cache/image_loader.dart b/mobile/lib/modules/asset_viewer/image_providers/cache/image_loader.dart index e5204acde5..209955bcb5 100644 --- a/mobile/lib/modules/asset_viewer/image_providers/cache/image_loader.dart +++ b/mobile/lib/modules/asset_viewer/image_providers/cache/image_loader.dart @@ -16,8 +16,6 @@ class ImageLoader { required ImageCacheManager cache, required ImageDecoderCallback decode, StreamController? 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; }