b9639650e5
Port the web client's list/save/delete schedule request shapes and reply checks, with a typed record that preserves the whole server payload including unknown fields. Revision stays the CAS token; server refusals propagate unchanged.
23 lines
691 B
Dart
23 lines
691 B
Dart
import '../../../core/api_gateway.dart';
|
|
|
|
/// Deep copy of a decoded JSON value.
|
|
///
|
|
/// Saved schedules travel back to the server unchanged, so unknown fields (and
|
|
/// unknown nested values) must survive every round trip without sharing state
|
|
/// with the reply map that produced them.
|
|
dynamic cloneJsonValue(dynamic value) {
|
|
if (value is Map) {
|
|
return <String, dynamic>{
|
|
for (final entry in value.entries)
|
|
'${entry.key}': cloneJsonValue(entry.value),
|
|
};
|
|
}
|
|
if (value is List) {
|
|
return [for (final item in value) cloneJsonValue(item)];
|
|
}
|
|
return value;
|
|
}
|
|
|
|
JsonMap cloneJsonMap(JsonMap value) =>
|
|
Map<String, dynamic>.from(cloneJsonValue(value) as Map);
|