nice overview working
This commit is contained in:
@@ -30,6 +30,7 @@ class BankController extends ChangeNotifier {
|
||||
_remoteTransactions = cached.transactions;
|
||||
}
|
||||
_importedTransactions = _storage?.loadImportedTransactions() ?? const [];
|
||||
_invalidateMerged();
|
||||
}
|
||||
|
||||
final IngtrakApi _api;
|
||||
@@ -39,6 +40,7 @@ class BankController extends ChangeNotifier {
|
||||
BankBalance? _balance;
|
||||
List<BankTransaction> _remoteTransactions = const [];
|
||||
List<BankTransaction> _importedTransactions = const [];
|
||||
List<BankTransaction>? _mergedTransactions;
|
||||
|
||||
bool _isLoading = false;
|
||||
bool _isConnecting = false;
|
||||
@@ -50,8 +52,16 @@ class BankController extends ChangeNotifier {
|
||||
BankBalance? get balance => _balance;
|
||||
|
||||
/// Remote API txs merged with locally imported CSV txs (deduped).
|
||||
///
|
||||
/// Cached — [mergeTransactions] is O(n·m) and was re-running on every
|
||||
/// `bank.transactions` read during rebuilds.
|
||||
List<BankTransaction> get transactions =>
|
||||
mergeTransactions(_remoteTransactions, _importedTransactions);
|
||||
_mergedTransactions ??=
|
||||
mergeTransactions(_remoteTransactions, _importedTransactions);
|
||||
|
||||
void _invalidateMerged() {
|
||||
_mergedTransactions = null;
|
||||
}
|
||||
|
||||
int get importedCount => _importedTransactions.length;
|
||||
bool get isLoading => _isLoading;
|
||||
@@ -121,6 +131,7 @@ class BankController extends ChangeNotifier {
|
||||
_remoteTransactions,
|
||||
_importedTransactions,
|
||||
);
|
||||
_invalidateMerged();
|
||||
await _persistImported();
|
||||
}
|
||||
return result;
|
||||
@@ -139,6 +150,7 @@ class BankController extends ChangeNotifier {
|
||||
|
||||
Future<void> clearImportedTransactions() async {
|
||||
_importedTransactions = const [];
|
||||
_invalidateMerged();
|
||||
await _storage?.clearImportedTransactions();
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -210,6 +222,7 @@ class BankController extends ChangeNotifier {
|
||||
_remoteTransactions,
|
||||
_importedTransactions,
|
||||
);
|
||||
_invalidateMerged();
|
||||
await _persistImported();
|
||||
_error = null;
|
||||
} on IngtrakApiException catch (error) {
|
||||
@@ -218,6 +231,7 @@ class BankController extends ChangeNotifier {
|
||||
_status = ConnectStatus.disconnected;
|
||||
_balance = null;
|
||||
_remoteTransactions = const [];
|
||||
_invalidateMerged();
|
||||
_error = error.message;
|
||||
await _persistCache();
|
||||
} else if (!hasData) {
|
||||
|
||||
Reference in New Issue
Block a user