OpenContacts/lib/models/records/asset_diff.dart

34 lines
811 B
Dart
Raw Normal View History

2023-05-16 09:59:31 -04:00
2023-09-30 06:22:32 -04:00
import 'package:contacts_plus_plus/models/records/resonite_db_asset.dart';
2023-09-29 03:51:46 -04:00
class AssetDiff extends ResoniteDBAsset{
2023-05-16 09:59:31 -04:00
final Diff state;
final bool isUploaded;
const AssetDiff({required hash, required bytes, required this.state, required this.isUploaded}) : super(hash: hash, bytes: bytes);
2023-05-16 09:59:31 -04:00
factory AssetDiff.fromMap(Map map) {
return AssetDiff(
hash: map["hash"],
bytes: map["bytes"],
state: Diff.fromInt(map["state"]),
isUploaded: map["isUploaded"],
);
}
}
enum Diff {
added,
unchanged,
removed;
factory Diff.fromInt(int? idx) {
return Diff.values[idx ?? 1];
}
factory Diff.fromString(String? text) {
return Diff.values.firstWhere((element) => element.name.toLowerCase() == text?.toLowerCase(),
orElse: () => Diff.unchanged,
);
}
}