mirror of
https://github.com/immich-app/immich.git
synced 2024-12-24 10:37:28 +02:00
1633af7af6
* introduce Asset as composition of AssetResponseDTO and AssetEntity * filter out duplicate assets (that are both local and remote, take only remote for now) * only allow remote images to be added to albums * introduce ImmichImage to render Asset using local or remote data * optimized deletion of local assets * local video file playback * allow multiple methods to wait on background service finished * skip local assets when adding to album from home screen * fix and optimize delete * show gray box placeholder for local assets * add comments * fix bug: duplicate assets in state after onNewAssetUploaded
78 lines
2.8 KiB
Dart
78 lines
2.8 KiB
Dart
import 'package:collection/collection.dart';
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
|
|
|
class AssetSelectionState {
|
|
final Set<String> selectedMonths;
|
|
final Set<Asset> selectedNewAssetsForAlbum;
|
|
final Set<Asset> selectedAdditionalAssetsForAlbum;
|
|
final Set<Asset> selectedAssetsInAlbumViewer;
|
|
final bool isMultiselectEnable;
|
|
|
|
/// Indicate the asset selection page is navigated from existing album
|
|
final bool isAlbumExist;
|
|
AssetSelectionState({
|
|
required this.selectedMonths,
|
|
required this.selectedNewAssetsForAlbum,
|
|
required this.selectedAdditionalAssetsForAlbum,
|
|
required this.selectedAssetsInAlbumViewer,
|
|
required this.isMultiselectEnable,
|
|
required this.isAlbumExist,
|
|
});
|
|
|
|
AssetSelectionState copyWith({
|
|
Set<String>? selectedMonths,
|
|
Set<Asset>? selectedNewAssetsForAlbum,
|
|
Set<Asset>? selectedAdditionalAssetsForAlbum,
|
|
Set<Asset>? selectedAssetsInAlbumViewer,
|
|
bool? isMultiselectEnable,
|
|
bool? isAlbumExist,
|
|
}) {
|
|
return AssetSelectionState(
|
|
selectedMonths: selectedMonths ?? this.selectedMonths,
|
|
selectedNewAssetsForAlbum:
|
|
selectedNewAssetsForAlbum ?? this.selectedNewAssetsForAlbum,
|
|
selectedAdditionalAssetsForAlbum: selectedAdditionalAssetsForAlbum ??
|
|
this.selectedAdditionalAssetsForAlbum,
|
|
selectedAssetsInAlbumViewer:
|
|
selectedAssetsInAlbumViewer ?? this.selectedAssetsInAlbumViewer,
|
|
isMultiselectEnable: isMultiselectEnable ?? this.isMultiselectEnable,
|
|
isAlbumExist: isAlbumExist ?? this.isAlbumExist,
|
|
);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AssetSelectionState(selectedMonths: $selectedMonths, selectedNewAssetsForAlbum: $selectedNewAssetsForAlbum, selectedAdditionalAssetsForAlbum: $selectedAdditionalAssetsForAlbum, selectedAssetsInAlbumViewer: $selectedAssetsInAlbumViewer, isMultiselectEnable: $isMultiselectEnable, isAlbumExist: $isAlbumExist)';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
final setEquals = const DeepCollectionEquality().equals;
|
|
|
|
return other is AssetSelectionState &&
|
|
setEquals(other.selectedMonths, selectedMonths) &&
|
|
setEquals(other.selectedNewAssetsForAlbum, selectedNewAssetsForAlbum) &&
|
|
setEquals(
|
|
other.selectedAdditionalAssetsForAlbum,
|
|
selectedAdditionalAssetsForAlbum,
|
|
) &&
|
|
setEquals(
|
|
other.selectedAssetsInAlbumViewer,
|
|
selectedAssetsInAlbumViewer,
|
|
) &&
|
|
other.isMultiselectEnable == isMultiselectEnable &&
|
|
other.isAlbumExist == isAlbumExist;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return selectedMonths.hashCode ^
|
|
selectedNewAssetsForAlbum.hashCode ^
|
|
selectedAdditionalAssetsForAlbum.hashCode ^
|
|
selectedAssetsInAlbumViewer.hashCode ^
|
|
isMultiselectEnable.hashCode ^
|
|
isAlbumExist.hashCode;
|
|
}
|
|
}
|