mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
feat adds proper syncing feature
Signed-off-by: Menno van Leeuwen <menno@vleeuwen.me>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'sync_enums.dart';
|
||||
import '../services/database_sync_service.dart';
|
||||
|
||||
class Ingredient {
|
||||
final int? id;
|
||||
@@ -9,7 +9,7 @@ class Ingredient {
|
||||
// Sync metadata
|
||||
final String syncId;
|
||||
final DateTime lastModified;
|
||||
final SyncStatus syncStatus;
|
||||
final RecordSyncStatus syncStatus;
|
||||
final bool isDeleted;
|
||||
|
||||
const Ingredient({
|
||||
@@ -19,7 +19,7 @@ class Ingredient {
|
||||
required this.unit,
|
||||
required this.syncId,
|
||||
required this.lastModified,
|
||||
this.syncStatus = SyncStatus.pending,
|
||||
this.syncStatus = RecordSyncStatus.pending,
|
||||
this.isDeleted = false,
|
||||
});
|
||||
|
||||
@@ -47,11 +47,11 @@ class Ingredient {
|
||||
? DateTime.parse(map['lastModified'])
|
||||
: DateTime.now(),
|
||||
syncStatus: map['syncStatus'] != null
|
||||
? SyncStatus.values.firstWhere(
|
||||
? RecordSyncStatus.values.firstWhere(
|
||||
(e) => e.name == map['syncStatus'],
|
||||
orElse: () => SyncStatus.pending,
|
||||
orElse: () => RecordSyncStatus.pending,
|
||||
)
|
||||
: SyncStatus.pending,
|
||||
: RecordSyncStatus.pending,
|
||||
isDeleted: (map['isDeleted'] ?? 0) == 1,
|
||||
);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class Ingredient {
|
||||
String? unit,
|
||||
String? syncId,
|
||||
DateTime? lastModified,
|
||||
SyncStatus? syncStatus,
|
||||
RecordSyncStatus? syncStatus,
|
||||
bool? isDeleted,
|
||||
}) {
|
||||
return Ingredient(
|
||||
|
Reference in New Issue
Block a user