Updated on 2026-08-14
This commit is contained in:
parent
10599d6770
commit
0051a20463
4 changed files with 13 additions and 11 deletions
|
|
@ -1,13 +1,14 @@
|
|||
package com.tangem.datasource.local.accounts
|
||||
|
||||
import com.tangem.domain.models.account.AccountName
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface AccountTokenMigrationStore {
|
||||
|
||||
fun get(userWalletId: UserWalletId): Flow<Pair<String, String>?>
|
||||
fun get(userWalletId: UserWalletId): Flow<Pair<AccountName, AccountName>?>
|
||||
|
||||
suspend fun store(userWalletId: UserWalletId, value: Pair<String, String>)
|
||||
suspend fun store(userWalletId: UserWalletId, value: Pair<AccountName, AccountName>)
|
||||
|
||||
suspend fun remove(userWalletId: UserWalletId)
|
||||
}
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
package com.tangem.datasource.local.accounts
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeStateStore
|
||||
import com.tangem.domain.models.account.AccountName
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
internal class DefaultAccountTokenMigrationStore(
|
||||
private val runtimeStateStore: RuntimeStateStore<Map<UserWalletId, Pair<String, String>>>,
|
||||
private val runtimeStateStore: RuntimeStateStore<Map<UserWalletId, Pair<AccountName, AccountName>>>,
|
||||
) : AccountTokenMigrationStore {
|
||||
|
||||
override fun get(userWalletId: UserWalletId): Flow<Pair<String, String>?> {
|
||||
override fun get(userWalletId: UserWalletId): Flow<Pair<AccountName, AccountName>?> {
|
||||
return runtimeStateStore.get().map { it[userWalletId] }
|
||||
}
|
||||
|
||||
override suspend fun store(userWalletId: UserWalletId, value: Pair<String, String>) {
|
||||
override suspend fun store(userWalletId: UserWalletId, value: Pair<AccountName, AccountName>) {
|
||||
runtimeStateStore.update { it + (userWalletId to value) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import arrow.core.raise.ensureNotNull
|
|||
import arrow.core.toNonEmptyListOrNull
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.data.account.converter.AccountNameConverter
|
||||
import com.tangem.data.account.converter.toDerivationIndex
|
||||
import com.tangem.data.account.store.AccountsResponseStoreFactory
|
||||
import com.tangem.data.account.utils.assignTokens
|
||||
|
|
@ -144,11 +145,9 @@ internal class DefaultMainAccountTokensMigration(
|
|||
|
||||
store.updateData { updatedResponse }
|
||||
|
||||
val mainAccountName = mainAccount.name
|
||||
val selectedAccountName = selectedAccount.name
|
||||
if (mainAccountName != null && selectedAccountName != null) {
|
||||
accountTokenMigrationStore.store(userWalletId, mainAccountName to selectedAccountName)
|
||||
}
|
||||
val mainAccountName = AccountNameConverter.convertBack(mainAccount.name)
|
||||
val selectedAccountName = AccountNameConverter.convertBack(selectedAccount.name)
|
||||
accountTokenMigrationStore.store(userWalletId, mainAccountName to selectedAccountName)
|
||||
|
||||
val userTokensResponse = updatedResponse.toUserTokensResponse()
|
||||
userTokensSaver.pushWithRetryer(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.arkivanov.decompose.extensions.compose.subscribeAsState
|
|||
import com.arkivanov.decompose.router.slot.childSlot
|
||||
import com.arkivanov.decompose.router.slot.dismiss
|
||||
import com.arkivanov.essenty.lifecycle.subscribe
|
||||
import com.tangem.common.ui.account.toUM
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.context.childByContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
|
|
@ -146,7 +147,7 @@ internal class DefaultWalletSettingsComponent @AssistedInject constructor(
|
|||
title = resourceReference(R.string.accounts_migration_alert_title),
|
||||
message = resourceReference(
|
||||
R.string.accounts_migration_alert_message,
|
||||
wrappedList(fromAccount, toAccount),
|
||||
wrappedList(fromAccount.toUM().value, toAccount.toUM().value),
|
||||
),
|
||||
firstActionBuilder = {
|
||||
EventMessageAction(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue