fix: syncNewPayments() replaces the list without deduplicating against what's already displayed
This commit is contained in:
@@ -140,12 +140,13 @@ class HistoryViewModel(
|
|||||||
// Reload first page from DB to reflect any newly merged payments
|
// Reload first page from DB to reflect any newly merged payments
|
||||||
val refreshed = paymentCache.loadCachedPage(
|
val refreshed = paymentCache.loadCachedPage(
|
||||||
offset = 0,
|
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(
|
_state.value = HistoryState.Success(
|
||||||
payments = refreshed,
|
payments = merged,
|
||||||
canLoadMore = refreshed.size >= WalletConstants.PAYMENTS_PAGE_SIZE,
|
canLoadMore = refreshed.size >= currentOffset.coerceAtLeast(WalletConstants.PAYMENTS_PAGE_SIZE),
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user