Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import org.mytonwallet.app_air.uipasscode.viewControllers.passcodeConfirm.Passco
import org.mytonwallet.app_air.uistake.confirm.ConfirmStakingHeaderView
import org.mytonwallet.app_air.uistake.earn.cells.EarnItemCell
import org.mytonwallet.app_air.uistake.earn.cells.EarnSpaceCell
import org.mytonwallet.app_air.uistake.earn.models.EarnItem
import org.mytonwallet.app_air.uistake.earn.views.EarnHeaderView
import org.mytonwallet.app_air.uistake.helpers.StakingMessageHelpers
import org.mytonwallet.app_air.uistake.staking.StakingVC
Expand All @@ -67,6 +68,8 @@ import org.mytonwallet.app_air.walletbasecontext.theme.color
import org.mytonwallet.app_air.walletbasecontext.utils.toString
import org.mytonwallet.app_air.walletcontext.utils.IndexPath
import org.mytonwallet.app_air.walletcontext.utils.colorWithAlpha
import org.mytonwallet.app_air.walletcontext.utils.diff
import org.mytonwallet.app_air.walletcontext.utils.WEquatable
import org.mytonwallet.app_air.walletcore.MYCOIN_SLUG
import org.mytonwallet.app_air.walletcore.TONCOIN_SLUG
import org.mytonwallet.app_air.walletcore.USDE_SLUG
Expand Down Expand Up @@ -508,6 +511,15 @@ class EarnVC(
}

private var lastListState: HistoryListState? = null
private var previousHistoryItems: List<WEquatable<*>> = emptyList()

private fun maybeUpdateRecyclerView(newItems: List<EarnItem>) {
// Use the built-in diff() extension function
val changes = previousHistoryItems.diff(newItems, section = 1)
rvAdapter.applyChanges(changes)
previousHistoryItems = newItems.toList() // Store copy for next comparison
}

private fun updateView(viewState: EarnViewState) {
// balance
headerView.apply {
Expand Down Expand Up @@ -564,8 +576,7 @@ class EarnVC(
recyclerView.overScrollMode = RecyclerView.OVER_SCROLL_ALWAYS
noItemView.visibility = View.GONE
updateSkeletonState()
rvAdapter.reloadData()

maybeUpdateRecyclerView(viewState.historyListState.historyItems)
}
}
lastListState = viewState.historyListState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ sealed class EarnItem(
}

override fun isChanged(comparing: WEquatable<*>): Boolean {
return false
return if (comparing is EarnItem && comparing::class == this::class) {
comparing.formattedAmount != formattedAmount ||
comparing.amountInBaseCurrency != amountInBaseCurrency
} else false
}

data class Profit(
Expand Down