Add rejected mutation requeue flow in sync UI
This commit is contained in:
@@ -11,6 +11,7 @@ class SyncState {
|
||||
this.lastAttemptAt,
|
||||
this.lastError,
|
||||
this.lastRejected = const <MutationRejection>[],
|
||||
this.lastRejectedChanges = const <ChangeEnvelope>[],
|
||||
});
|
||||
|
||||
factory SyncState.fromJson(Map<String, dynamic> json) {
|
||||
@@ -31,6 +32,13 @@ class SyncState {
|
||||
MutationRejection.fromJson(item as Map<String, dynamic>),
|
||||
)
|
||||
.toList(growable: false),
|
||||
lastRejectedChanges:
|
||||
(json['lastRejectedChanges'] as List<dynamic>? ?? <dynamic>[])
|
||||
.map(
|
||||
(dynamic item) =>
|
||||
ChangeEnvelope.fromJson(item as Map<String, dynamic>),
|
||||
)
|
||||
.toList(growable: false),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,12 +48,14 @@ class SyncState {
|
||||
final DateTime? lastAttemptAt;
|
||||
final String? lastError;
|
||||
final List<MutationRejection> lastRejected;
|
||||
final List<ChangeEnvelope> lastRejectedChanges;
|
||||
|
||||
static const Object _unset = Object();
|
||||
|
||||
static const SyncState empty = SyncState(
|
||||
pendingChanges: <ChangeEnvelope>[],
|
||||
lastRejected: <MutationRejection>[],
|
||||
lastRejectedChanges: <ChangeEnvelope>[],
|
||||
);
|
||||
|
||||
SyncState copyWith({
|
||||
@@ -55,6 +65,7 @@ class SyncState {
|
||||
Object? lastAttemptAt = _unset,
|
||||
Object? lastError = _unset,
|
||||
List<MutationRejection>? lastRejected,
|
||||
List<ChangeEnvelope>? lastRejectedChanges,
|
||||
}) {
|
||||
return SyncState(
|
||||
cursor: identical(cursor, _unset) ? this.cursor : cursor as String?,
|
||||
@@ -69,6 +80,7 @@ class SyncState {
|
||||
? this.lastError
|
||||
: lastError as String?,
|
||||
lastRejected: lastRejected ?? this.lastRejected,
|
||||
lastRejectedChanges: lastRejectedChanges ?? this.lastRejectedChanges,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,6 +96,9 @@ class SyncState {
|
||||
'lastRejected': lastRejected
|
||||
.map((MutationRejection rejection) => rejection.toJson())
|
||||
.toList(growable: false),
|
||||
'lastRejectedChanges': lastRejectedChanges
|
||||
.map((ChangeEnvelope change) => change.toJson())
|
||||
.toList(growable: false),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user