Skip to content

Commit

Permalink
Fixes equality operator for immich local image provider
Browse files Browse the repository at this point in the history
  • Loading branch information
martyfuhry committed Apr 22, 2024
1 parent c9a0792 commit d5575cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions mobile/lib/shared/cache/custom_image_cache.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d5575cc

Please sign in to comment.