mirror of
https://github.com/immich-app/immich.git
synced 2025-12-24 01:11:32 +03:00
fix(mobile): Fixes memory image cache for local images (#9019)
* Fixes equality operator for immich local image provider * Changes image cache manager to no longer be image cache managers * Updates large image cache to 12 images format * Try 5 Image cache --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@ import 'package:immich_mobile/shared/models/store.dart';
|
||||
class ImageLoader {
|
||||
static Future<ui.Codec> loadImageFromCache(
|
||||
String uri, {
|
||||
required ImageCacheManager cache,
|
||||
required CacheManager cache,
|
||||
required ImageDecoderCallback decode,
|
||||
StreamController<ImageChunkEvent>? chunkEvents,
|
||||
}) async {
|
||||
@@ -21,7 +21,7 @@ class ImageLoader {
|
||||
'x-immich-user-token': Store.get(StoreKey.accessToken),
|
||||
};
|
||||
|
||||
final stream = cache.getImageFile(
|
||||
final stream = cache.getFileStream(
|
||||
uri,
|
||||
withProgress: chunkEvents != null,
|
||||
headers: headers,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
|
||||
/// The cache manager for full size images [ImmichRemoteImageProvider]
|
||||
class RemoteImageCacheManager extends CacheManager with ImageCacheManager {
|
||||
class RemoteImageCacheManager extends CacheManager {
|
||||
static const key = 'remoteImageCacheKey';
|
||||
static final RemoteImageCacheManager _instance = RemoteImageCacheManager._();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
|
||||
/// The cache manager for thumbnail images [ImmichRemoteThumbnailProvider]
|
||||
class ThumbnailImageCacheManager extends CacheManager with ImageCacheManager {
|
||||
class ThumbnailImageCacheManager extends CacheManager {
|
||||
static const key = 'thumbnailImageCacheKey';
|
||||
static final ThumbnailImageCacheManager _instance =
|
||||
ThumbnailImageCacheManager._();
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'package:immich_mobile/shared/models/asset.dart';
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
|
||||
/// The local image provider for an asset
|
||||
/// Only viable
|
||||
class ImmichLocalImageProvider extends ImageProvider<ImmichLocalImageProvider> {
|
||||
final Asset asset;
|
||||
|
||||
@@ -94,9 +93,12 @@ class ImmichLocalImageProvider extends ImageProvider<ImmichLocalImageProvider> {
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (other is! ImmichLocalImageProvider) return false;
|
||||
if (identical(this, other)) return true;
|
||||
return asset == other.asset;
|
||||
if (other is ImmichLocalImageProvider) {
|
||||
return asset == other.asset;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -21,7 +21,7 @@ class ImmichRemoteImageProvider
|
||||
final String assetId;
|
||||
|
||||
/// The image cache manager
|
||||
final ImageCacheManager? cacheManager;
|
||||
final CacheManager? cacheManager;
|
||||
|
||||
ImmichRemoteImageProvider({
|
||||
required this.assetId,
|
||||
@@ -66,7 +66,7 @@ class ImmichRemoteImageProvider
|
||||
// Streams in each stage of the image as we ask for it
|
||||
Stream<ui.Codec> _codec(
|
||||
ImmichRemoteImageProvider key,
|
||||
ImageCacheManager cache,
|
||||
CacheManager cache,
|
||||
ImageDecoderCallback decode,
|
||||
StreamController<ImageChunkEvent> chunkEvents,
|
||||
) async* {
|
||||
|
||||
@@ -22,7 +22,7 @@ class ImmichRemoteThumbnailProvider
|
||||
final int? width;
|
||||
|
||||
/// The image cache manager
|
||||
final ImageCacheManager? cacheManager;
|
||||
final CacheManager? cacheManager;
|
||||
|
||||
ImmichRemoteThumbnailProvider({
|
||||
required this.assetId,
|
||||
@@ -55,7 +55,7 @@ class ImmichRemoteThumbnailProvider
|
||||
// Streams in each stage of the image as we ask for it
|
||||
Stream<ui.Codec> _codec(
|
||||
ImmichRemoteThumbnailProvider key,
|
||||
ImageCacheManager cache,
|
||||
CacheManager cache,
|
||||
ImageDecoderCallback decode,
|
||||
) async* {
|
||||
// Load a preview to the chunk events
|
||||
|
||||
Reference in New Issue
Block a user