mirror of
https://github.com/immich-app/immich.git
synced 2024-11-17 19:08:49 -07: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
85 lines
2.2 KiB
Dart
85 lines
2.2 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:collection/collection.dart';
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
class SearchResultPageState {
|
|
final bool isLoading;
|
|
final bool isSuccess;
|
|
final bool isError;
|
|
final List<Asset> searchResult;
|
|
|
|
SearchResultPageState({
|
|
required this.isLoading,
|
|
required this.isSuccess,
|
|
required this.isError,
|
|
required this.searchResult,
|
|
});
|
|
|
|
SearchResultPageState copyWith({
|
|
bool? isLoading,
|
|
bool? isSuccess,
|
|
bool? isError,
|
|
List<Asset>? searchResult,
|
|
}) {
|
|
return SearchResultPageState(
|
|
isLoading: isLoading ?? this.isLoading,
|
|
isSuccess: isSuccess ?? this.isSuccess,
|
|
isError: isError ?? this.isError,
|
|
searchResult: searchResult ?? this.searchResult,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'isLoading': isLoading,
|
|
'isSuccess': isSuccess,
|
|
'isError': isError,
|
|
'searchResult': searchResult.map((x) => x.toJson()).toList(),
|
|
};
|
|
}
|
|
|
|
factory SearchResultPageState.fromMap(Map<String, dynamic> map) {
|
|
return SearchResultPageState(
|
|
isLoading: map['isLoading'] ?? false,
|
|
isSuccess: map['isSuccess'] ?? false,
|
|
isError: map['isError'] ?? false,
|
|
searchResult: List<Asset>.from(
|
|
map['searchResult']
|
|
?.map((x) => Asset.remote(AssetResponseDto.fromJson(x))),
|
|
),
|
|
);
|
|
}
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory SearchResultPageState.fromJson(String source) =>
|
|
SearchResultPageState.fromMap(json.decode(source));
|
|
|
|
@override
|
|
String toString() {
|
|
return 'SearchresultPageState(isLoading: $isLoading, isSuccess: $isSuccess, isError: $isError, searchResult: $searchResult)';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
final listEquals = const DeepCollectionEquality().equals;
|
|
|
|
return other is SearchResultPageState &&
|
|
other.isLoading == isLoading &&
|
|
other.isSuccess == isSuccess &&
|
|
other.isError == isError &&
|
|
listEquals(other.searchResult, searchResult);
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return isLoading.hashCode ^
|
|
isSuccess.hashCode ^
|
|
isError.hashCode ^
|
|
searchResult.hashCode;
|
|
}
|
|
}
|