From d84b6711ffc505217010e2a1a66056121fc0eac5 Mon Sep 17 00:00:00 2001 From: rasputin Date: Mon, 1 Jun 2026 21:53:51 +0200 Subject: [PATCH] fix: syncNewPayments() replaces the list without deduplicating against what's already displayed --- .../com/bitcointxoko/gudariwallet/ui/HistoryViewModel.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/bitcointxoko/gudariwallet/ui/HistoryViewModel.kt b/app/src/main/java/com/bitcointxoko/gudariwallet/ui/HistoryViewModel.kt index 21dce95..f0df4f2 100644 --- a/app/src/main/java/com/bitcointxoko/gudariwallet/ui/HistoryViewModel.kt +++ b/app/src/main/java/com/bitcointxoko/gudariwallet/ui/HistoryViewModel.kt @@ -140,12 +140,13 @@ class HistoryViewModel( // Reload first page from DB to reflect any newly merged payments val refreshed = paymentCache.loadCachedPage( offset = 0, - limit = WalletConstants.PAYMENTS_PAGE_SIZE + limit = currentOffset.coerceAtLeast(WalletConstants.PAYMENTS_PAGE_SIZE) ) - currentOffset = refreshed.size + val merged = (refreshed + ((_state.value as? HistoryState.Success)?.payments ?: emptyList())) + .distinctBy { it.paymentHash } _state.value = HistoryState.Success( - payments = refreshed, - canLoadMore = refreshed.size >= WalletConstants.PAYMENTS_PAGE_SIZE, + payments = merged, + canLoadMore = refreshed.size >= currentOffset.coerceAtLeast(WalletConstants.PAYMENTS_PAGE_SIZE), isRefreshing = false ) }