mirror of
https://github.com/cogwheel0/conduit.git
synced 2026-08-29 13:31:44 +00:00
- Updated conversation fetching methods to utilize new summary parsing functions, improving clarity and performance. - Refactored the handling of pinned and archived conversations to enhance data retrieval efficiency. - Introduced normalization utilities for JSON data handling across various services, ensuring consistent data structures. - Simplified error handling and data coercion processes in conversation parsing, enhancing robustness. - Updated related tests to reflect changes in data structures and ensure comprehensive coverage.
23 lines
676 B
Dart
23 lines
676 B
Dart
/// Utilities for deep-cloning JSON-like structures without a JSON round trip.
|
|
library;
|
|
|
|
Object? normalizeJsonLikeValue(Object? value) {
|
|
if (value == null || value is String || value is num || value is bool) {
|
|
return value;
|
|
}
|
|
if (value is Map) {
|
|
return normalizeJsonLikeMap(value);
|
|
}
|
|
if (value is Iterable) {
|
|
return value.map(normalizeJsonLikeValue).toList(growable: false);
|
|
}
|
|
return value;
|
|
}
|
|
|
|
Map<String, dynamic> normalizeJsonLikeMap(Map<dynamic, dynamic> value) {
|
|
final normalized = <String, dynamic>{};
|
|
value.forEach((key, entryValue) {
|
|
normalized[key?.toString() ?? ''] = normalizeJsonLikeValue(entryValue);
|
|
});
|
|
return normalized;
|
|
}
|