mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
Refactor mobile to use OpenApi generated SDK (#336)
This commit is contained in:
parent
d69470e207
commit
ae7e582ec8
276 changed files with 14513 additions and 3003 deletions
|
|
@ -1,84 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class CuratedLocation {
|
||||
final String id;
|
||||
final String city;
|
||||
final String resizePath;
|
||||
final String deviceAssetId;
|
||||
final String deviceId;
|
||||
|
||||
CuratedLocation({
|
||||
required this.id,
|
||||
required this.city,
|
||||
required this.resizePath,
|
||||
required this.deviceAssetId,
|
||||
required this.deviceId,
|
||||
});
|
||||
|
||||
CuratedLocation copyWith({
|
||||
String? id,
|
||||
String? city,
|
||||
String? resizePath,
|
||||
String? deviceAssetId,
|
||||
String? deviceId,
|
||||
}) {
|
||||
return CuratedLocation(
|
||||
id: id ?? this.id,
|
||||
city: city ?? this.city,
|
||||
resizePath: resizePath ?? this.resizePath,
|
||||
deviceAssetId: deviceAssetId ?? this.deviceAssetId,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'city': city,
|
||||
'resizePath': resizePath,
|
||||
'deviceAssetId': deviceAssetId,
|
||||
'deviceId': deviceId,
|
||||
};
|
||||
}
|
||||
|
||||
factory CuratedLocation.fromMap(Map<String, dynamic> map) {
|
||||
return CuratedLocation(
|
||||
id: map['id'] ?? '',
|
||||
city: map['city'] ?? '',
|
||||
resizePath: map['resizePath'] ?? '',
|
||||
deviceAssetId: map['deviceAssetId'] ?? '',
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CuratedLocation.fromJson(String source) =>
|
||||
CuratedLocation.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CuratedLocation(id: $id, city: $city, resizePath: $resizePath, deviceAssetId: $deviceAssetId, deviceId: $deviceId)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is CuratedLocation &&
|
||||
other.id == id &&
|
||||
other.city == city &&
|
||||
other.resizePath == resizePath &&
|
||||
other.deviceAssetId == deviceAssetId &&
|
||||
other.deviceId == deviceId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
city.hashCode ^
|
||||
resizePath.hashCode ^
|
||||
deviceAssetId.hashCode ^
|
||||
deviceId.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class CuratedObject {
|
||||
final String id;
|
||||
final String object;
|
||||
final String resizePath;
|
||||
final String deviceAssetId;
|
||||
final String deviceId;
|
||||
CuratedObject({
|
||||
required this.id,
|
||||
required this.object,
|
||||
required this.resizePath,
|
||||
required this.deviceAssetId,
|
||||
required this.deviceId,
|
||||
});
|
||||
|
||||
CuratedObject copyWith({
|
||||
String? id,
|
||||
String? object,
|
||||
String? resizePath,
|
||||
String? deviceAssetId,
|
||||
String? deviceId,
|
||||
}) {
|
||||
return CuratedObject(
|
||||
id: id ?? this.id,
|
||||
object: object ?? this.object,
|
||||
resizePath: resizePath ?? this.resizePath,
|
||||
deviceAssetId: deviceAssetId ?? this.deviceAssetId,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final result = <String, dynamic>{};
|
||||
|
||||
result.addAll({'id': id});
|
||||
result.addAll({'object': object});
|
||||
result.addAll({'resizePath': resizePath});
|
||||
result.addAll({'deviceAssetId': deviceAssetId});
|
||||
result.addAll({'deviceId': deviceId});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
factory CuratedObject.fromMap(Map<String, dynamic> map) {
|
||||
return CuratedObject(
|
||||
id: map['id'] ?? '',
|
||||
object: map['object'] ?? '',
|
||||
resizePath: map['resizePath'] ?? '',
|
||||
deviceAssetId: map['deviceAssetId'] ?? '',
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CuratedObject.fromJson(String source) =>
|
||||
CuratedObject.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CuratedObject(id: $id, object: $object, resizePath: $resizePath, deviceAssetId: $deviceAssetId, deviceId: $deviceId)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is CuratedObject &&
|
||||
other.id == id &&
|
||||
other.object == object &&
|
||||
other.resizePath == resizePath &&
|
||||
other.deviceAssetId == deviceAssetId &&
|
||||
other.deviceId == deviceId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
object.hashCode ^
|
||||
resizePath.hashCode ^
|
||||
deviceAssetId.hashCode ^
|
||||
deviceId.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:immich_mobile/shared/models/immich_asset.model.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class SearchResultPageState {
|
||||
final bool isLoading;
|
||||
final bool isSuccess;
|
||||
final bool isError;
|
||||
final List<ImmichAsset> searchResult;
|
||||
final List<AssetResponseDto> searchResult;
|
||||
|
||||
SearchResultPageState({
|
||||
required this.isLoading,
|
||||
|
|
@ -20,7 +20,7 @@ class SearchResultPageState {
|
|||
bool? isLoading,
|
||||
bool? isSuccess,
|
||||
bool? isError,
|
||||
List<ImmichAsset>? searchResult,
|
||||
List<AssetResponseDto>? searchResult,
|
||||
}) {
|
||||
return SearchResultPageState(
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
|
|
@ -35,7 +35,7 @@ class SearchResultPageState {
|
|||
'isLoading': isLoading,
|
||||
'isSuccess': isSuccess,
|
||||
'isError': isError,
|
||||
'searchResult': searchResult.map((x) => x.toMap()).toList(),
|
||||
'searchResult': searchResult.map((x) => x.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -44,8 +44,9 @@ class SearchResultPageState {
|
|||
isLoading: map['isLoading'] ?? false,
|
||||
isSuccess: map['isSuccess'] ?? false,
|
||||
isError: map['isError'] ?? false,
|
||||
searchResult: List<ImmichAsset>.from(
|
||||
map['searchResult']?.map((x) => ImmichAsset.fromMap(x))),
|
||||
searchResult: List<AssetResponseDto>.from(
|
||||
map['searchResult']?.map((x) => AssetResponseDto.mapFromJson(x)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue