sync transactions with pocketbase 2
This commit is contained in:
@@ -155,6 +155,35 @@ class BankController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Union cloud txs into the local bank cache without dropping either side.
|
||||
///
|
||||
/// Rows land in the API cache; CSV imports that match are deduped away.
|
||||
Future<void> applySyncedTransactions(List<BankTransaction> fromCloud) async {
|
||||
if (fromCloud.isEmpty) return;
|
||||
|
||||
_remoteTransactions = mergeTransactions(_remoteTransactions, fromCloud);
|
||||
_importedTransactions = filterNewTransactions(
|
||||
_remoteTransactions,
|
||||
_importedTransactions,
|
||||
);
|
||||
_invalidateMerged();
|
||||
|
||||
if (!_status.linked && _remoteTransactions.isNotEmpty) {
|
||||
_status = ConnectStatus(
|
||||
status: _status.status == 'disconnected' ? 'synced' : _status.status,
|
||||
linked: true,
|
||||
accountId: _status.accountId,
|
||||
sessionId: _status.sessionId,
|
||||
state: _status.state,
|
||||
validUntil: _status.validUntil,
|
||||
);
|
||||
}
|
||||
|
||||
await _persistCache();
|
||||
await _persistImported();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Load status; if linked, also load balance + transactions.
|
||||
Future<void> refresh() async {
|
||||
_isLoading = true;
|
||||
|
||||
Reference in New Issue
Block a user