mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00: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:
parent
2943f93098
commit
732bd1e652
7 changed files with 18 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue