mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor: library type (#9525)
This commit is contained in:
parent
4353153fe6
commit
84d824d6a7
66 changed files with 183 additions and 984 deletions
14
mobile/openapi/lib/model/asset_response_dto.dart
generated
14
mobile/openapi/lib/model/asset_response_dto.dart
generated
|
|
@ -29,7 +29,7 @@ class AssetResponseDto {
|
|||
required this.isOffline,
|
||||
this.isReadOnly,
|
||||
required this.isTrashed,
|
||||
required this.libraryId,
|
||||
this.libraryId,
|
||||
this.livePhotoVideoId,
|
||||
required this.localDateTime,
|
||||
required this.originalFileName,
|
||||
|
|
@ -101,7 +101,8 @@ class AssetResponseDto {
|
|||
|
||||
bool isTrashed;
|
||||
|
||||
String libraryId;
|
||||
/// This property was deprecated in v1.106.0
|
||||
String? libraryId;
|
||||
|
||||
String? livePhotoVideoId;
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ class AssetResponseDto {
|
|||
(isOffline.hashCode) +
|
||||
(isReadOnly == null ? 0 : isReadOnly!.hashCode) +
|
||||
(isTrashed.hashCode) +
|
||||
(libraryId.hashCode) +
|
||||
(libraryId == null ? 0 : libraryId!.hashCode) +
|
||||
(livePhotoVideoId == null ? 0 : livePhotoVideoId!.hashCode) +
|
||||
(localDateTime.hashCode) +
|
||||
(originalFileName.hashCode) +
|
||||
|
|
@ -257,7 +258,11 @@ class AssetResponseDto {
|
|||
// json[r'isReadOnly'] = null;
|
||||
}
|
||||
json[r'isTrashed'] = this.isTrashed;
|
||||
if (this.libraryId != null) {
|
||||
json[r'libraryId'] = this.libraryId;
|
||||
} else {
|
||||
// json[r'libraryId'] = null;
|
||||
}
|
||||
if (this.livePhotoVideoId != null) {
|
||||
json[r'livePhotoVideoId'] = this.livePhotoVideoId;
|
||||
} else {
|
||||
|
|
@ -325,7 +330,7 @@ class AssetResponseDto {
|
|||
isOffline: mapValueOfType<bool>(json, r'isOffline')!,
|
||||
isReadOnly: mapValueOfType<bool>(json, r'isReadOnly'),
|
||||
isTrashed: mapValueOfType<bool>(json, r'isTrashed')!,
|
||||
libraryId: mapValueOfType<String>(json, r'libraryId')!,
|
||||
libraryId: mapValueOfType<String>(json, r'libraryId'),
|
||||
livePhotoVideoId: mapValueOfType<String>(json, r'livePhotoVideoId'),
|
||||
localDateTime: mapDateTime(json, r'localDateTime', r'')!,
|
||||
originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
|
||||
|
|
@ -401,7 +406,6 @@ class AssetResponseDto {
|
|||
'isFavorite',
|
||||
'isOffline',
|
||||
'isTrashed',
|
||||
'libraryId',
|
||||
'localDateTime',
|
||||
'originalFileName',
|
||||
'originalPath',
|
||||
|
|
|
|||
14
mobile/openapi/lib/model/create_library_dto.dart
generated
14
mobile/openapi/lib/model/create_library_dto.dart
generated
|
|
@ -17,7 +17,6 @@ class CreateLibraryDto {
|
|||
this.importPaths = const [],
|
||||
this.name,
|
||||
required this.ownerId,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
List<String> exclusionPatterns;
|
||||
|
|
@ -34,15 +33,12 @@ class CreateLibraryDto {
|
|||
|
||||
String ownerId;
|
||||
|
||||
LibraryType type;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is CreateLibraryDto &&
|
||||
_deepEquality.equals(other.exclusionPatterns, exclusionPatterns) &&
|
||||
_deepEquality.equals(other.importPaths, importPaths) &&
|
||||
other.name == name &&
|
||||
other.ownerId == ownerId &&
|
||||
other.type == type;
|
||||
other.ownerId == ownerId;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
|
|
@ -50,11 +46,10 @@ class CreateLibraryDto {
|
|||
(exclusionPatterns.hashCode) +
|
||||
(importPaths.hashCode) +
|
||||
(name == null ? 0 : name!.hashCode) +
|
||||
(ownerId.hashCode) +
|
||||
(type.hashCode);
|
||||
(ownerId.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'CreateLibraryDto[exclusionPatterns=$exclusionPatterns, importPaths=$importPaths, name=$name, ownerId=$ownerId, type=$type]';
|
||||
String toString() => 'CreateLibraryDto[exclusionPatterns=$exclusionPatterns, importPaths=$importPaths, name=$name, ownerId=$ownerId]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
|
|
@ -66,7 +61,6 @@ class CreateLibraryDto {
|
|||
// json[r'name'] = null;
|
||||
}
|
||||
json[r'ownerId'] = this.ownerId;
|
||||
json[r'type'] = this.type;
|
||||
return json;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +80,6 @@ class CreateLibraryDto {
|
|||
: const [],
|
||||
name: mapValueOfType<String>(json, r'name'),
|
||||
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
||||
type: LibraryType.fromJson(json[r'type'])!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
|
@ -135,7 +128,6 @@ class CreateLibraryDto {
|
|||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'ownerId',
|
||||
'type',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
10
mobile/openapi/lib/model/library_response_dto.dart
generated
10
mobile/openapi/lib/model/library_response_dto.dart
generated
|
|
@ -21,7 +21,6 @@ class LibraryResponseDto {
|
|||
required this.name,
|
||||
required this.ownerId,
|
||||
required this.refreshedAt,
|
||||
required this.type,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
|
|
@ -41,8 +40,6 @@ class LibraryResponseDto {
|
|||
|
||||
DateTime? refreshedAt;
|
||||
|
||||
LibraryType type;
|
||||
|
||||
DateTime updatedAt;
|
||||
|
||||
@override
|
||||
|
|
@ -55,7 +52,6 @@ class LibraryResponseDto {
|
|||
other.name == name &&
|
||||
other.ownerId == ownerId &&
|
||||
other.refreshedAt == refreshedAt &&
|
||||
other.type == type &&
|
||||
other.updatedAt == updatedAt;
|
||||
|
||||
@override
|
||||
|
|
@ -69,11 +65,10 @@ class LibraryResponseDto {
|
|||
(name.hashCode) +
|
||||
(ownerId.hashCode) +
|
||||
(refreshedAt == null ? 0 : refreshedAt!.hashCode) +
|
||||
(type.hashCode) +
|
||||
(updatedAt.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'LibraryResponseDto[assetCount=$assetCount, createdAt=$createdAt, exclusionPatterns=$exclusionPatterns, id=$id, importPaths=$importPaths, name=$name, ownerId=$ownerId, refreshedAt=$refreshedAt, type=$type, updatedAt=$updatedAt]';
|
||||
String toString() => 'LibraryResponseDto[assetCount=$assetCount, createdAt=$createdAt, exclusionPatterns=$exclusionPatterns, id=$id, importPaths=$importPaths, name=$name, ownerId=$ownerId, refreshedAt=$refreshedAt, updatedAt=$updatedAt]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
|
|
@ -89,7 +84,6 @@ class LibraryResponseDto {
|
|||
} else {
|
||||
// json[r'refreshedAt'] = null;
|
||||
}
|
||||
json[r'type'] = this.type;
|
||||
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
|
||||
return json;
|
||||
}
|
||||
|
|
@ -114,7 +108,6 @@ class LibraryResponseDto {
|
|||
name: mapValueOfType<String>(json, r'name')!,
|
||||
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
||||
refreshedAt: mapDateTime(json, r'refreshedAt', r''),
|
||||
type: LibraryType.fromJson(json[r'type'])!,
|
||||
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
|
||||
);
|
||||
}
|
||||
|
|
@ -171,7 +164,6 @@ class LibraryResponseDto {
|
|||
'name',
|
||||
'ownerId',
|
||||
'refreshedAt',
|
||||
'type',
|
||||
'updatedAt',
|
||||
};
|
||||
}
|
||||
|
|
|
|||
85
mobile/openapi/lib/model/library_type.dart
generated
85
mobile/openapi/lib/model/library_type.dart
generated
|
|
@ -1,85 +0,0 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class LibraryType {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const LibraryType._(this.value);
|
||||
|
||||
/// The underlying value of this enum member.
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
static const UPLOAD = LibraryType._(r'UPLOAD');
|
||||
static const EXTERNAL = LibraryType._(r'EXTERNAL');
|
||||
|
||||
/// List of all possible values in this [enum][LibraryType].
|
||||
static const values = <LibraryType>[
|
||||
UPLOAD,
|
||||
EXTERNAL,
|
||||
];
|
||||
|
||||
static LibraryType? fromJson(dynamic value) => LibraryTypeTypeTransformer().decode(value);
|
||||
|
||||
static List<LibraryType> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <LibraryType>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = LibraryType.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [LibraryType] to String,
|
||||
/// and [decode] dynamic data back to [LibraryType].
|
||||
class LibraryTypeTypeTransformer {
|
||||
factory LibraryTypeTypeTransformer() => _instance ??= const LibraryTypeTypeTransformer._();
|
||||
|
||||
const LibraryTypeTypeTransformer._();
|
||||
|
||||
String encode(LibraryType data) => data.value;
|
||||
|
||||
/// Decodes a [dynamic value][data] to a LibraryType.
|
||||
///
|
||||
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
|
||||
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
|
||||
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
LibraryType? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data) {
|
||||
case r'UPLOAD': return LibraryType.UPLOAD;
|
||||
case r'EXTERNAL': return LibraryType.EXTERNAL;
|
||||
default:
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Singleton [LibraryTypeTypeTransformer] instance.
|
||||
static LibraryTypeTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue