mirror of
https://github.com/immich-app/immich.git
synced 2024-12-24 10:37:28 +02:00
5ad4e5b614
* fix: add correct relations to asset typeorm entity * fix: add missing createdAt column to asset entity * ci: run check to make sure generated API is up-to-date * ci: cancel workflows that aren't for the latest commit in a branch * chore: add fvm config for flutter
79 lines
1.9 KiB
Dart
79 lines
1.9 KiB
Dart
import 'dart:convert';
|
|
|
|
class CurrentUploadAsset {
|
|
final String id;
|
|
final DateTime fileCreatedAt;
|
|
final String fileName;
|
|
final String fileType;
|
|
|
|
CurrentUploadAsset({
|
|
required this.id,
|
|
required this.fileCreatedAt,
|
|
required this.fileName,
|
|
required this.fileType,
|
|
});
|
|
|
|
CurrentUploadAsset copyWith({
|
|
String? id,
|
|
DateTime? fileCreatedAt,
|
|
String? fileName,
|
|
String? fileType,
|
|
}) {
|
|
return CurrentUploadAsset(
|
|
id: id ?? this.id,
|
|
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
|
|
fileName: fileName ?? this.fileName,
|
|
fileType: fileType ?? this.fileType,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
final result = <String, dynamic>{};
|
|
|
|
result.addAll({'id': id});
|
|
result.addAll({'fileCreatedAt': fileCreatedAt.millisecondsSinceEpoch});
|
|
result.addAll({'fileName': fileName});
|
|
result.addAll({'fileType': fileType});
|
|
|
|
return result;
|
|
}
|
|
|
|
factory CurrentUploadAsset.fromMap(Map<String, dynamic> map) {
|
|
return CurrentUploadAsset(
|
|
id: map['id'] ?? '',
|
|
fileCreatedAt: DateTime.fromMillisecondsSinceEpoch(map['fileCreatedAt']),
|
|
fileName: map['fileName'] ?? '',
|
|
fileType: map['fileType'] ?? '',
|
|
);
|
|
}
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory CurrentUploadAsset.fromJson(String source) =>
|
|
CurrentUploadAsset.fromMap(json.decode(source));
|
|
|
|
@override
|
|
String toString() {
|
|
return 'CurrentUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType)';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
|
|
return other is CurrentUploadAsset &&
|
|
other.id == id &&
|
|
other.fileCreatedAt == fileCreatedAt &&
|
|
other.fileName == fileName &&
|
|
other.fileType == fileType;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return id.hashCode ^
|
|
fileCreatedAt.hashCode ^
|
|
fileName.hashCode ^
|
|
fileType.hashCode;
|
|
}
|
|
}
|