Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-14 13:07:15 +05:00
parent e78794533d
commit a07ee6d71f

View file

@ -24,6 +24,7 @@ import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.nft.DisableWalletNFTUseCase
import com.tangem.domain.nft.EnableWalletNFTUseCase
import com.tangem.domain.nft.GetWalletNFTEnabledUseCase
import com.tangem.domain.notifications.GetApplicationIdUseCase
import com.tangem.domain.notifications.toggles.NotificationsFeatureToggles
import com.tangem.domain.settings.repositories.PermissionRepository
import com.tangem.domain.wallets.models.UserWallet
@ -44,6 +45,7 @@ import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnaly
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import timber.log.Timber
@ -72,6 +74,8 @@ internal class WalletSettingsModel @Inject constructor(
private val setNotificationsEnabledUseCase: SetNotificationsEnabledUseCase,
private val settingsManager: SettingsManager,
private val permissionsRepository: PermissionRepository,
private val getApplicationIdUseCase: GetApplicationIdUseCase,
private val associateWalletsWithApplicationIdUseCase: AssociateWalletsWithApplicationIdUseCase,
) : Model() {
val params: WalletSettingsComponent.Params = paramsContainer.require()
@ -194,10 +198,20 @@ internal class WalletSettingsModel @Inject constructor(
if (hasUserWallets) {
router.pop()
} else {
clearWalletsAssociatedWithApplicationId()
router.replaceAll(AppRoute.Home)
}
}
private fun clearWalletsAssociatedWithApplicationId() = modelScope.launch(NonCancellable) {
getApplicationIdUseCase().onRight { applicationId ->
associateWalletsWithApplicationIdUseCase(applicationId, emptyList())
.onLeft {
Timber.e("Unable to associate empty wallets with application ID: $it")
}
}
}
private fun onLinkMoreCardsClick(scanResponse: ScanResponse) {
analyticsEventHandler.send(Settings.ButtonCreateBackup)
analyticsContextProxy.addContext(scanResponse)