Added tags to asset

This commit is contained in:
Alex Phillips 2023-07-09 12:00:51 -04:00
parent 659a754b98
commit 7422319d9c
2 changed files with 19 additions and 9 deletions

View file

@ -30,7 +30,8 @@ class Asset {
exifInfo =
remote.exifInfo != null ? ExifInfo.fromDto(remote.exifInfo!) : null,
isFavorite = remote.isFavorite,
isArchived = remote.isArchived;
isArchived = remote.isArchived,
tags = remote.tags;
Asset.local(AssetEntity local, List<int> hash)
: localId = local.id,
@ -45,7 +46,8 @@ class Asset {
updatedAt = local.modifiedDateTime,
isFavorite = local.isFavorite,
isArchived = false,
fileCreatedAt = local.createDateTime {
fileCreatedAt = local.createDateTime,
tags = [] {
if (fileCreatedAt.year == 1970) {
fileCreatedAt = fileModifiedAt;
}
@ -74,6 +76,7 @@ class Asset {
this.exifInfo,
required this.isFavorite,
required this.isArchived,
required this.tags,
});
@ignore
@ -139,6 +142,8 @@ class Asset {
bool isArchived;
List<dynamic> tags;
@ignore
ExifInfo? exifInfo;
@ -216,7 +221,8 @@ class Asset {
livePhotoVideoId.hashCode ^
isFavorite.hashCode ^
isLocal.hashCode ^
isArchived.hashCode;
isArchived.hashCode ^
tags.hashCode;
/// Returns `true` if this [Asset] can updated with values from parameter [a]
bool canUpdate(Asset a) {
@ -306,6 +312,7 @@ class Asset {
String? livePhotoVideoId,
bool? isFavorite,
bool? isArchived,
List<dynamic>? tags,
ExifInfo? exifInfo,
}) =>
Asset(
@ -326,6 +333,7 @@ class Asset {
isFavorite: isFavorite ?? this.isFavorite,
isArchived: isArchived ?? this.isArchived,
exifInfo: exifInfo ?? this.exifInfo,
tags: tags ?? [],
);
Future<void> put(Isar db) async {
@ -365,15 +373,15 @@ class Asset {
"remoteId": "${remoteId ?? "N/A"}",
"localId": "${localId ?? "N/A"}",
"checksum": "$checksum",
"ownerId": $ownerId,
"ownerId": $ownerId,
"livePhotoVideoId": "${livePhotoVideoId ?? "N/A"}",
"fileCreatedAt": "$fileCreatedAt",
"fileModifiedAt": "$fileModifiedAt",
"updatedAt": "$updatedAt",
"durationInSeconds": $durationInSeconds,
"fileModifiedAt": "$fileModifiedAt",
"updatedAt": "$updatedAt",
"durationInSeconds": $durationInSeconds,
"type": "$type",
"fileName": "$fileName",
"isFavorite": $isFavorite,
"fileName": "$fileName",
"isFavorite": $isFavorite,
"isRemote: $isRemote,
"storage": "$storage",
"width": ${width ?? "N/A"},

View file

@ -203,6 +203,7 @@ void _assetSerialize(
writer.writeByte(offsets[12], object.type.index);
writer.writeDateTime(offsets[13], object.updatedAt);
writer.writeInt(offsets[14], object.width);
writer.writeString(offsets[15], jsonEncode(object.tags));
}
Asset _assetDeserialize(
@ -229,6 +230,7 @@ Asset _assetDeserialize(
AssetType.other,
updatedAt: reader.readDateTime(offsets[13]),
width: reader.readIntOrNull(offsets[14]),
tags: jsonDecode(reader.readString(offsets[15])),
);
return object;
}