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:
parent
5ef6215546
commit
1abb0bdae8
1 changed files with 3 additions and 11 deletions
|
@ -16,8 +16,6 @@ class ImageLoader {
|
||||||
required ImageCacheManager cache,
|
required ImageCacheManager cache,
|
||||||
required ImageDecoderCallback decode,
|
required ImageDecoderCallback decode,
|
||||||
StreamController<ImageChunkEvent>? chunkEvents,
|
StreamController<ImageChunkEvent>? chunkEvents,
|
||||||
int? height,
|
|
||||||
int? width,
|
|
||||||
}) async {
|
}) async {
|
||||||
final headers = {
|
final headers = {
|
||||||
'x-immich-user-token': Store.get(StoreKey.accessToken),
|
'x-immich-user-token': Store.get(StoreKey.accessToken),
|
||||||
|
@ -25,10 +23,8 @@ class ImageLoader {
|
||||||
|
|
||||||
final stream = cache.getImageFile(
|
final stream = cache.getImageFile(
|
||||||
uri,
|
uri,
|
||||||
withProgress: true,
|
withProgress: chunkEvents != null,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
maxHeight: height,
|
|
||||||
maxWidth: width,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await for (final result in stream) {
|
await for (final result in stream) {
|
||||||
|
@ -40,13 +36,9 @@ class ImageLoader {
|
||||||
expectedTotalBytes: result.totalSize,
|
expectedTotalBytes: result.totalSize,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
} else if (result is FileInfo) {
|
||||||
|
|
||||||
if (result is FileInfo) {
|
|
||||||
// We have the file
|
// We have the file
|
||||||
final file = result.file;
|
final buffer = await ui.ImmutableBuffer.fromFilePath(result.file.path);
|
||||||
final bytes = await file.readAsBytes();
|
|
||||||
final buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
|
|
||||||
final decoded = await decode(buffer);
|
final decoded = await decode(buffer);
|
||||||
return decoded;
|
return decoded;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue