Skip to content

Commit a21d713

Browse files
committed
Update condition model to include lastUpdated time.
1 parent 42b7df1 commit a21d713

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/src/api/models/condition.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,15 @@ sealed class BaseCondition with EquatableMixin, SerializableMixin {
333333
/// id of the condition
334334
final String id;
335335

336+
/// last updated timestamp
337+
@JsonKey(fromJson: jsonToDate, toJson: dateToJson)
338+
final DateTime lastUpdated;
339+
336340
/// Creates a base condition.
337-
const BaseCondition({required this.id});
341+
BaseCondition({
342+
required this.id,
343+
DateTime? lastUpdated,
344+
}) : lastUpdated = lastUpdated ?? DateTime.now();
338345

339346
/// Factory constructor for creating a new [BaseCondition] instance from
340347
/// JSON data.
@@ -369,6 +376,7 @@ class ElseCondition extends BaseCondition {
369376
ElseCondition({
370377
required super.id,
371378
List<ActionModel>? actions,
379+
super.lastUpdated,
372380
}) : actions = actions ?? [];
373381

374382
/// Duplicates the else condition with the provided actions list.
@@ -379,6 +387,7 @@ class ElseCondition extends BaseCondition {
379387
return ElseCondition(
380388
id: id ?? this.id,
381389
actions: actions ?? this.actions,
390+
lastUpdated: DateTime.now(),
382391
);
383392
}
384393

@@ -413,11 +422,12 @@ class Condition extends BaseCondition {
413422
final ConditionMode mode;
414423

415424
/// Creates a simple condition
416-
const Condition({
425+
Condition({
417426
required super.id,
418427
required this.mode,
419428
required this.expression,
420429
required this.actions,
430+
super.lastUpdated,
421431
});
422432

423433
/// CopyWith
@@ -431,6 +441,7 @@ class Condition extends BaseCondition {
431441
mode: mode,
432442
expression: expression ?? this.expression,
433443
actions: actions ?? this.actions,
444+
lastUpdated: DateTime.now(),
434445
);
435446
}
436447

@@ -474,6 +485,7 @@ class ConditionGroup extends BaseCondition {
474485
required this.ifCondition,
475486
List<Condition>? elseIfConditions,
476487
this.elseCondition,
488+
super.lastUpdated,
477489
}) : elseIfConditions = elseIfConditions ?? [];
478490

479491
/// CopyWith
@@ -490,6 +502,7 @@ class ConditionGroup extends BaseCondition {
490502
ifCondition: ifCondition ?? this.ifCondition,
491503
elseIfConditions: elseIfConditions ?? this.elseIfConditions,
492504
elseCondition: elseCondition ?? this.elseCondition,
505+
lastUpdated: DateTime.now(),
493506
);
494507
}
495508

lib/src/api/models/condition.g.dart

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)