mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +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';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
|
|
||||||
class TrashedAsset {
|
class TrashedAsset extends LocalAsset {
|
||||||
final String id;
|
|
||||||
final String name;
|
|
||||||
final String? volume;
|
final String? volume;
|
||||||
final String albumId;
|
final String albumId;
|
||||||
final String? checksum;
|
|
||||||
final AssetType type;
|
|
||||||
final DateTime createdAt;
|
|
||||||
final DateTime updatedAt;
|
|
||||||
|
|
||||||
const TrashedAsset({
|
const TrashedAsset({
|
||||||
required this.id,
|
|
||||||
required this.name,
|
|
||||||
required this.albumId,
|
required this.albumId,
|
||||||
required this.type,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
this.volume,
|
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({
|
TrashedAsset copyWith({
|
||||||
String? id,
|
String? id,
|
||||||
|
String? remoteId,
|
||||||
String? name,
|
String? name,
|
||||||
String? volume,
|
|
||||||
String? albumId,
|
|
||||||
String? checksum,
|
String? checksum,
|
||||||
AssetType? type,
|
AssetType? type,
|
||||||
DateTime? createdAt,
|
DateTime? createdAt,
|
||||||
DateTime? updatedAt,
|
DateTime? updatedAt,
|
||||||
|
int? width,
|
||||||
|
int? height,
|
||||||
|
int? durationInSeconds,
|
||||||
|
bool? isFavorite,
|
||||||
|
String? livePhotoVideoId,
|
||||||
|
int? orientation,
|
||||||
|
String? albumId,
|
||||||
|
String? volume,
|
||||||
}) {
|
}) {
|
||||||
return TrashedAsset(
|
return TrashedAsset(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
|
remoteId: remoteId ?? this.remoteId,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
volume: volume ?? this.volume,
|
|
||||||
albumId: albumId ?? this.albumId,
|
|
||||||
checksum: checksum ?? this.checksum,
|
checksum: checksum ?? this.checksum,
|
||||||
type: type ?? this.type,
|
type: type ?? this.type,
|
||||||
createdAt: createdAt ?? this.createdAt,
|
createdAt: createdAt ?? this.createdAt,
|
||||||
updatedAt: updatedAt ?? this.updatedAt,
|
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
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
other is TrashedAsset &&
|
other is TrashedAsset &&
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
id == other.id &&
|
// LocalAsset identity
|
||||||
name == other.name &&
|
id == other.id &&
|
||||||
volume == other.volume &&
|
name == other.name &&
|
||||||
albumId == other.albumId &&
|
remoteId == other.remoteId &&
|
||||||
checksum == other.checksum &&
|
checksum == other.checksum &&
|
||||||
type == other.type &&
|
type == other.type &&
|
||||||
createdAt == other.createdAt &&
|
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
|
@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(),
|
updatedAt: tryFromSecondsSinceEpoch(updatedAt) ?? DateTime.now(),
|
||||||
volume: volume,
|
volume: volume,
|
||||||
albumId: albumId,
|
albumId: albumId,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
durationInSeconds: durationInSeconds,
|
||||||
|
isFavorite: isFavorite,
|
||||||
|
orientation: orientation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,10 @@ extension TrashedLocalAssetEntityDataDomainExtension on TrashedLocalAssetEntityD
|
||||||
type: type,
|
type: type,
|
||||||
createdAt: createdAt,
|
createdAt: createdAt,
|
||||||
updatedAt: updatedAt,
|
updatedAt: updatedAt,
|
||||||
|
durationInSeconds: durationInSeconds,
|
||||||
|
isFavorite: isFavorite,
|
||||||
|
height: height,
|
||||||
|
width: width,
|
||||||
|
orientation: orientation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,11 @@ class DriftTrashedLocalAssetRepository extends DriftDatabaseRepository {
|
||||||
type: a.type,
|
type: a.type,
|
||||||
createdAt: Value(a.createdAt),
|
createdAt: Value(a.createdAt),
|
||||||
updatedAt: Value(a.updatedAt),
|
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,
|
type: a.type,
|
||||||
checksum: a.checksum == null ? const Value.absent() : Value(a.checksum),
|
checksum: a.checksum == null ? const Value.absent() : Value(a.checksum),
|
||||||
createdAt: Value(a.createdAt),
|
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