nice overview working
This commit is contained in:
@@ -17,6 +17,7 @@ class TxMetaStoreData {
|
||||
this.notesByMerchant = const {},
|
||||
this.exactTemplates = const {},
|
||||
this.customLabels = const [],
|
||||
this.labelParents = const {},
|
||||
});
|
||||
|
||||
final Map<String, TxMeta> byId;
|
||||
@@ -24,6 +25,9 @@ class TxMetaStoreData {
|
||||
final Map<String, String> notesByMerchant;
|
||||
final Map<String, TxExactTemplate> exactTemplates;
|
||||
final List<TxLabel> customLabels;
|
||||
|
||||
/// childLabelId → parentLabelId (roots omitted).
|
||||
final Map<String, String> labelParents;
|
||||
}
|
||||
|
||||
/// Cached bank payload so the app stays usable across restarts / brief outages.
|
||||
@@ -236,6 +240,7 @@ class StorageService {
|
||||
'customLabels': [
|
||||
for (final label in store.customLabels) label.toJson(),
|
||||
],
|
||||
'labelParents': store.labelParents,
|
||||
};
|
||||
return _prefs.setString(StorageKeys.txMeta, jsonEncode(encoded));
|
||||
}
|
||||
@@ -323,12 +328,35 @@ class StorageService {
|
||||
}
|
||||
}
|
||||
|
||||
final labelParents = <String, String>{};
|
||||
final parentsRaw = root['labelParents'];
|
||||
if (parentsRaw is Map) {
|
||||
parentsRaw.forEach((key, value) {
|
||||
if (key is String &&
|
||||
value is String &&
|
||||
key.isNotEmpty &&
|
||||
value.isNotEmpty) {
|
||||
labelParents[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
// Prefer explicit map; fall back to parentId embedded on custom labels.
|
||||
for (final label in customLabels) {
|
||||
final parent = label.parentId;
|
||||
if (parent != null &&
|
||||
parent.isNotEmpty &&
|
||||
!labelParents.containsKey(label.id)) {
|
||||
labelParents[label.id] = parent;
|
||||
}
|
||||
}
|
||||
|
||||
return TxMetaStoreData(
|
||||
byId: byId,
|
||||
labelsByMerchant: labelsByMerchant,
|
||||
notesByMerchant: notesByMerchant,
|
||||
exactTemplates: exactTemplates,
|
||||
customLabels: customLabels,
|
||||
labelParents: labelParents,
|
||||
);
|
||||
} catch (_) {
|
||||
return const TxMetaStoreData();
|
||||
|
||||
Reference in New Issue
Block a user