fix: syncNewPayments() replaces the list without deduplicating against what's already displayed

This commit is contained in:
2026-06-01 21:53:51 +02:00
parent 2715d13f7e
commit d84b6711ff
@@ -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
)
}