ente/lib/models/local_entity_data.dart

49 lines
1,022 B
Dart
Raw Normal View History

2023-04-05 03:24:00 +00:00
import "package:equatable/equatable.dart";
import "package:photos/models/api/entity/type.dart";
class LocalEntityData {
final String id;
final EntityType type;
final String data;
final int ownerID;
final int updatedAt;
LocalEntityData({
required this.id,
required this.type,
required this.data,
required this.ownerID,
required this.updatedAt,
});
Map<String, dynamic> toJson() {
return {
"id": id,
"type": type.typeToString(),
"data": data,
"ownerID": ownerID,
"updatedAt": updatedAt,
};
}
factory LocalEntityData.fromJson(Map<String, dynamic> json) {
return LocalEntityData(
id: json["id"],
type: typeFromString(json["type"]),
data: json["data"],
2023-04-04 08:48:54 +00:00
ownerID: json["ownerID"] as int,
updatedAt: json["updatedAt"] as int,
);
}
}
2023-04-04 08:48:54 +00:00
2023-04-05 03:24:00 +00:00
class LocalEntity<T> extends Equatable {
2023-04-04 08:48:54 +00:00
final T item;
final String id;
2023-04-05 03:24:00 +00:00
const LocalEntity(this.item, this.id);
@override
List<Object?> get props => [item, id];
2023-04-04 08:48:54 +00:00
}