You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-07-14 07:04:24 +02: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:
@ -1,12 +1,14 @@
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:immich_mobile/modules/asset_viewer/image_providers/immich_local_image_provider.dart';
|
||||
import 'package:immich_mobile/modules/asset_viewer/image_providers/immich_local_thumbnail_provider.dart';
|
||||
import 'package:immich_mobile/modules/asset_viewer/image_providers/immich_remote_image_provider.dart';
|
||||
import 'package:immich_mobile/modules/asset_viewer/image_providers/immich_remote_thumbnail_provider.dart';
|
||||
|
||||
/// [ImageCache] that uses two caches for small and large images
|
||||
/// so that a single large image does not evict all small iamges
|
||||
final class CustomImageCache implements ImageCache {
|
||||
final _small = ImageCache();
|
||||
final _large = ImageCache();
|
||||
final _large = ImageCache()..maximumSize = 5; // Maximum 5 images
|
||||
|
||||
@override
|
||||
int get maximumSize => _small.maximumSize + _large.maximumSize;
|
||||
@ -33,6 +35,8 @@ final class CustomImageCache implements ImageCache {
|
||||
}
|
||||
|
||||
/// Gets the cache for the given key
|
||||
/// [_large] is used for [ImmichLocalImageProvider] and [ImmichRemoteImageProvider]
|
||||
/// [_small] is used for [ImmichLocalThumbnailProvider] and [ImmichRemoteThumbnailProvider]
|
||||
ImageCache _cacheForKey(Object key) =>
|
||||
(key is ImmichLocalImageProvider || key is ImmichRemoteImageProvider)
|
||||
? _large
|
||||
|
Reference in New Issue
Block a user