Updated on 2026-08-14
This commit is contained in:
parent
80ec72c173
commit
e8c5c35e56
11 changed files with 89 additions and 44 deletions
|
|
@ -63,7 +63,14 @@ internal abstract class BasicTokenListSubscriber(
|
|||
transform = { maybeTokenList, maybeAppCurrency ->
|
||||
val tokenList = maybeTokenList.getOrElse(
|
||||
ifLoading = { maybeContent ->
|
||||
maybeContent ?: return@combine
|
||||
val isRefreshing = stateHolder.getWalletState(userWallet.walletId)
|
||||
?.pullToRefreshConfig
|
||||
?.isRefreshing
|
||||
?: false
|
||||
|
||||
maybeContent
|
||||
?.takeIf { !isRefreshing }
|
||||
?: return@combine
|
||||
},
|
||||
ifError = { e ->
|
||||
Timber.e("Failed to load token list: $e")
|
||||
|
|
|
|||
|
|
@ -53,9 +53,8 @@ internal class MultiWalletTokenListSubscriber(
|
|||
updateSortingIfNeeded(maybeTokenList)
|
||||
}
|
||||
|
||||
private suspend fun updateSortingIfNeeded(maybeTokenList: Lce<TokenListError, TokenList>) {
|
||||
val tokenList = maybeTokenList.getOrNull() ?: return
|
||||
if (!checkNeedSorting(tokenList)) return
|
||||
private suspend fun updateSortingIfNeeded(maybeTokenList: Lce<*, TokenList>) {
|
||||
val tokenList = getTokenList(maybeTokenList) ?: return
|
||||
|
||||
applyTokenListSortingUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
|
|
@ -65,9 +64,14 @@ internal class MultiWalletTokenListSubscriber(
|
|||
)
|
||||
}
|
||||
|
||||
private fun checkNeedSorting(tokenList: TokenList): Boolean {
|
||||
return tokenList.totalFiatBalance !is TotalFiatBalance.Loading &&
|
||||
tokenList.sortedBy == TokenList.SortType.BALANCE
|
||||
private fun getTokenList(lce: Lce<*, TokenList>): TokenList? {
|
||||
val tokenList = lce.getOrNull(isPartialContentAccepted = false)
|
||||
?: return null
|
||||
|
||||
return tokenList.takeIf {
|
||||
tokenList.totalFiatBalance is TotalFiatBalance.Loaded &&
|
||||
tokenList.sortedBy == TokenList.SortType.BALANCE
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrenciesIds(tokenList: TokenList): List<CryptoCurrency.ID> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue