mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor TrashedAsset model
fix missed data transfering
This commit is contained in:
parent
ccc86d8440
commit
4b2b99942c
4 changed files with 110 additions and 42 deletions
|
|
@ -1,76 +1,124 @@
|
|||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
|
||||
class TrashedAsset {
|
||||
final String id;
|
||||
final String name;
|
||||
class TrashedAsset extends LocalAsset {
|
||||
final String? volume;
|
||||
final String albumId;
|
||||
final String? checksum;
|
||||
final AssetType type;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
|
||||
const TrashedAsset({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.albumId,
|
||||
required this.type,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.volume,
|
||||
this.checksum,
|
||||
required super.id,
|
||||
super.remoteId,
|
||||
required super.name,
|
||||
super.checksum,
|
||||
required super.type,
|
||||
required super.createdAt,
|
||||
required super.updatedAt,
|
||||
super.width,
|
||||
super.height,
|
||||
super.durationInSeconds,
|
||||
super.isFavorite = false,
|
||||
super.livePhotoVideoId,
|
||||
super.orientation = 0,
|
||||
});
|
||||
|
||||
@override
|
||||
TrashedAsset copyWith({
|
||||
String? id,
|
||||
String? remoteId,
|
||||
String? name,
|
||||
String? volume,
|
||||
String? albumId,
|
||||
String? checksum,
|
||||
AssetType? type,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
int? width,
|
||||
int? height,
|
||||
int? durationInSeconds,
|
||||
bool? isFavorite,
|
||||
String? livePhotoVideoId,
|
||||
int? orientation,
|
||||
String? albumId,
|
||||
String? volume,
|
||||
}) {
|
||||
return TrashedAsset(
|
||||
id: id ?? this.id,
|
||||
remoteId: remoteId ?? this.remoteId,
|
||||
name: name ?? this.name,
|
||||
volume: volume ?? this.volume,
|
||||
albumId: albumId ?? this.albumId,
|
||||
checksum: checksum ?? this.checksum,
|
||||
type: type ?? this.type,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
width: width ?? this.width,
|
||||
height: height ?? this.height,
|
||||
durationInSeconds: durationInSeconds ?? this.durationInSeconds,
|
||||
isFavorite: isFavorite ?? this.isFavorite,
|
||||
livePhotoVideoId: livePhotoVideoId ?? this.livePhotoVideoId,
|
||||
orientation: orientation ?? this.orientation,
|
||||
albumId: albumId ?? this.albumId,
|
||||
volume: volume ?? this.volume,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TrashedAsset('
|
||||
'id: $id, '
|
||||
'name: $name, '
|
||||
'volume: $volume, '
|
||||
'albumId: $albumId, '
|
||||
'checksum: $checksum, '
|
||||
'type: $type, '
|
||||
'createdAt: $createdAt, '
|
||||
'updatedAt: $updatedAt, '
|
||||
')';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is TrashedAsset &&
|
||||
runtimeType == other.runtimeType &&
|
||||
// LocalAsset identity
|
||||
id == other.id &&
|
||||
name == other.name &&
|
||||
volume == other.volume &&
|
||||
albumId == other.albumId &&
|
||||
remoteId == other.remoteId &&
|
||||
checksum == other.checksum &&
|
||||
type == other.type &&
|
||||
createdAt == other.createdAt &&
|
||||
updatedAt == other.updatedAt;
|
||||
updatedAt == other.updatedAt &&
|
||||
width == other.width &&
|
||||
height == other.height &&
|
||||
durationInSeconds == other.durationInSeconds &&
|
||||
isFavorite == other.isFavorite &&
|
||||
livePhotoVideoId == other.livePhotoVideoId &&
|
||||
orientation == other.orientation &&
|
||||
// TrashedAsset extras
|
||||
volume == other.volume &&
|
||||
albumId == other.albumId;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, name, volume, albumId, checksum, type, createdAt, updatedAt);
|
||||
int get hashCode => Object.hash(
|
||||
id,
|
||||
name,
|
||||
remoteId,
|
||||
checksum,
|
||||
type,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
width,
|
||||
height,
|
||||
durationInSeconds,
|
||||
isFavorite,
|
||||
livePhotoVideoId,
|
||||
orientation,
|
||||
volume,
|
||||
albumId,
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TrashedAsset('
|
||||
'id: $id, '
|
||||
'remoteId: $remoteId, '
|
||||
'name: $name, '
|
||||
'checksum: $checksum, '
|
||||
'type: $type, '
|
||||
'createdAt: $createdAt, '
|
||||
'updatedAt: $updatedAt, '
|
||||
'width: $width, '
|
||||
'height: $height, '
|
||||
'durationInSeconds: $durationInSeconds, '
|
||||
'isFavorite: $isFavorite, '
|
||||
'livePhotoVideoId: $livePhotoVideoId, '
|
||||
'orientation: $orientation, '
|
||||
'albumId: $albumId, '
|
||||
'volume: $volume'
|
||||
')';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,6 +127,11 @@ extension on PlatformAsset {
|
|||
updatedAt: tryFromSecondsSinceEpoch(updatedAt) ?? DateTime.now(),
|
||||
volume: volume,
|
||||
albumId: albumId,
|
||||
width: width,
|
||||
height: height,
|
||||
durationInSeconds: durationInSeconds,
|
||||
isFavorite: isFavorite,
|
||||
orientation: orientation,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,5 +34,10 @@ extension TrashedLocalAssetEntityDataDomainExtension on TrashedLocalAssetEntityD
|
|||
type: type,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
durationInSeconds: durationInSeconds,
|
||||
isFavorite: isFavorite,
|
||||
height: height,
|
||||
width: width,
|
||||
orientation: orientation,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ class DriftTrashedLocalAssetRepository extends DriftDatabaseRepository {
|
|||
type: a.type,
|
||||
createdAt: Value(a.createdAt),
|
||||
updatedAt: Value(a.updatedAt),
|
||||
width: Value(a.width),
|
||||
height: Value(a.height),
|
||||
durationInSeconds: Value(a.durationInSeconds),
|
||||
isFavorite: Value(a.isFavorite),
|
||||
orientation: Value(a.orientation),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -108,6 +113,11 @@ class DriftTrashedLocalAssetRepository extends DriftDatabaseRepository {
|
|||
type: a.type,
|
||||
checksum: a.checksum == null ? const Value.absent() : Value(a.checksum),
|
||||
createdAt: Value(a.createdAt),
|
||||
width: Value(a.width),
|
||||
height: Value(a.height),
|
||||
durationInSeconds: Value(a.durationInSeconds),
|
||||
isFavorite: Value(a.isFavorite),
|
||||
orientation: Value(a.orientation),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue