Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-29 12:30:00 +04:00
commit 0b426b1981
7 changed files with 24 additions and 12 deletions

View file

@ -51,7 +51,7 @@ internal class BiometricUserWalletsListManager(
get() = state.value.isLocked
override val hasSavedUserWallets: Boolean
get() = publicInformationRepository.isNotEmpty()
get() = keysRepository.hasSavedEncryptionKeys()
override suspend fun unlockWithBiometry(): CompletionResult<UserWallet?> {
return unlockWithBiometryInternal()

View file

@ -32,4 +32,10 @@ internal interface UserWalletsKeysRepository {
* @return [CompletionResult] of operation
* */
suspend fun clear(): CompletionResult<Unit>
/**
* Determine if the user has saved user wallets
* @return [Boolean] true if user has saved wallets
* */
fun hasSavedEncryptionKeys(): Boolean
}

View file

@ -12,6 +12,4 @@ internal interface UserWalletsPublicInformationRepository {
suspend fun delete(walletIds: List<UserWalletId>): CompletionResult<Unit>
suspend fun clear(): CompletionResult<Unit>
fun isNotEmpty(): Boolean
}

View file

@ -17,6 +17,7 @@ import com.tangem.tap.domain.userWalletList.UserWalletListError
import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey
import com.tangem.tap.domain.userWalletList.repository.UserWalletsKeysRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
internal class BiometricUserWalletsKeysRepository(
@ -77,6 +78,12 @@ internal class BiometricUserWalletsKeysRepository(
}
}
override fun hasSavedEncryptionKeys(): Boolean {
return runBlocking {
getUserWalletsIds().isNotEmpty()
}
}
private suspend fun getAllInternal(): CompletionResult<List<UserWalletEncryptionKey>> {
return getUserWalletsIds()
.map { userWalletId ->

View file

@ -72,10 +72,6 @@ internal class DefaultUserWalletsPublicInformationRepository(
}
}
override fun isNotEmpty(): Boolean {
return secureStorage.get(StorageKey.UserWalletPublicInformation.name)?.isNotEmpty() == true
}
@JvmName("saveWithPublicInformation")
private suspend fun save(
publicInformation: List<UserWalletPublicInformation>,

View file

@ -278,9 +278,6 @@ class DetailsMiddleware {
val userWallet = UserWalletBuilder(scanResponse).build()
userWalletsListManager.save(userWallet)
.doOnFailure { error ->
Timber.e(error, "Wallet saving failed")
}
.doOnSuccess {
Analytics.send(Settings.AppSettings.SaveWalletSwitcherChanged(AnalyticsParam.OnOffState.On))
@ -296,6 +293,9 @@ class DetailsMiddleware {
store.onUserWalletSelected(userWallet)
}
.doOnFailure { error ->
Timber.e(error, "Unable to save user wallet")
}
}
private suspend fun deleteSavedWallets() {
@ -315,6 +315,9 @@ class DetailsMiddleware {
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Home))
}
.doOnFailure { error ->
Timber.e(error, "Unable to delete saved wallets")
}
}
private fun saveAccessCodes(state: DetailsState) {
@ -353,6 +356,9 @@ class DetailsMiddleware {
)
}
}
.doOnFailure { error ->
Timber.e(error, "Unable to delete saved access codes")
}
}
}
}

View file

@ -11,7 +11,6 @@ import com.tangem.tap.domain.extensions.signedHashesCount
import com.tangem.tap.preferencesStorage
import com.tangem.tap.store
import com.tangem.tap.tangemSdkManager
import com.tangem.tap.userWalletsListManager
import org.rekotlin.Action
import java.util.*
@ -57,7 +56,7 @@ private fun handlePrepareScreen(
createBackupAllowed = action.scanResponse.card.backupStatus == CardDTO.BackupStatus.NoBackup,
appCurrency = store.state.globalState.appCurrency,
isBiometricsAvailable = tangemSdkManager.canUseBiometry,
saveWallets = userWalletsListManager.hasSavedUserWallets,
saveWallets = preferencesStorage.shouldSaveUserWallets,
saveAccessCodes = preferencesStorage.shouldSaveAccessCodes,
)
}