Updated on 2026-08-14
This commit is contained in:
parent
0029b514bd
commit
3524a3bd86
7 changed files with 66 additions and 13 deletions
|
|
@ -11,10 +11,11 @@ import com.tangem.core.navigation.finisher.AppFinisher
|
|||
import com.tangem.feature.tester.impl.R
|
||||
import com.tangem.feature.tester.presentation.common.components.appbar.TopBarWithRefreshUM
|
||||
import com.tangem.feature.tester.presentation.featuretoggles.state.FeatureToggleGroupUM
|
||||
import com.tangem.feature.tester.presentation.featuretoggles.state.TesterFeatureToggleUM
|
||||
import com.tangem.feature.tester.presentation.featuretoggles.state.FeatureTogglesScreenUM
|
||||
import com.tangem.feature.tester.presentation.featuretoggles.state.TesterFeatureToggleUM
|
||||
import com.tangem.feature.tester.presentation.navigation.InnerTesterRouter
|
||||
import com.tangem.utils.info.AppInfoProvider
|
||||
import com.tangem.utils.logging.TangemLogger
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
|
@ -40,7 +41,7 @@ internal class FeatureTogglesViewModel @Inject constructor(
|
|||
) : ViewModel() {
|
||||
|
||||
// Declared before `state` so it is initialized before `initState()` runs in the field initializer.
|
||||
private val appVersion: Version? = Version.create(appInfoProvider.appVersion)
|
||||
private val appVersion: Version? = createAppVersion()
|
||||
|
||||
val state: StateFlow<FeatureTogglesScreenUM>
|
||||
field = MutableStateFlow(initState())
|
||||
|
|
@ -137,6 +138,20 @@ internal class FeatureTogglesViewModel @Inject constructor(
|
|||
.toImmutableList()
|
||||
}
|
||||
|
||||
private fun createAppVersion(): Version? {
|
||||
val rawVersion = appInfoProvider.appVersion
|
||||
// Drop the build-type suffix (e.g. "6.0-internal" -> "6.0") so the version parses, mirroring
|
||||
// DefaultVersionProvider; otherwise every toggle falls back to the "Not planned yet" group.
|
||||
val sanitizedVersion = rawVersion.substringBefore(delimiter = '-')
|
||||
val version = Version.create(sanitizedVersion)
|
||||
|
||||
if (version == null) {
|
||||
TangemLogger.e("Failed to parse app version: raw=$rawVersion, sanitized=$sanitizedVersion")
|
||||
}
|
||||
|
||||
return version
|
||||
}
|
||||
|
||||
private fun statusOf(toggleVersion: String): TesterFeatureToggleUM.Status {
|
||||
val toggle = parseToggleVersion(toggleVersion) ?: return TesterFeatureToggleUM.Status.UNDEFINED
|
||||
val app = appVersion ?: return TesterFeatureToggleUM.Status.UNDEFINED
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ internal interface WalletWarningsClickIntents {
|
|||
|
||||
fun onCloseAlreadySignedHashesWarningClick()
|
||||
|
||||
fun onGenerateMissedAddressesClick(missedAddressCurrencies: List<CryptoCurrency>)
|
||||
fun onGenerateMissedAddressesClick(userWalletId: UserWalletId, missedAddressCurrencies: List<CryptoCurrency>)
|
||||
|
||||
fun onOpenUnlockWalletsBottomSheetClick()
|
||||
|
||||
|
|
@ -164,19 +164,20 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onGenerateMissedAddressesClick(missedAddressCurrencies: List<CryptoCurrency>) {
|
||||
override fun onGenerateMissedAddressesClick(
|
||||
userWalletId: UserWalletId,
|
||||
missedAddressCurrencies: List<CryptoCurrency>,
|
||||
) {
|
||||
analyticsEventHandler.send(MainScreen.NoticeScanYourCardTapped())
|
||||
|
||||
modelScope.launch {
|
||||
val userWallet = getSelectedUserWallet() ?: return@launch
|
||||
|
||||
derivePublicKeysUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
userWalletId = userWalletId,
|
||||
currencies = missedAddressCurrencies,
|
||||
).fold(
|
||||
ifLeft = { TangemLogger.e("Failed to derive public keys", it) },
|
||||
ifRight = {
|
||||
fetchCryptoCurrencies(userWalletId = userWallet.walletId, currencies = missedAddressCurrencies)
|
||||
fetchCryptoCurrencies(userWalletId = userWalletId, currencies = missedAddressCurrencies)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,7 +336,10 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
tangemIcon = walletInterationIcon(userWallet),
|
||||
missingAddressesCount = currencies.count(),
|
||||
onGenerateClick = {
|
||||
clickIntents.onGenerateMissedAddressesClick(missedAddressCurrencies = currencies)
|
||||
clickIntents.onGenerateMissedAddressesClick(
|
||||
userWalletId = userWallet.walletId,
|
||||
missedAddressCurrencies = currencies,
|
||||
)
|
||||
},
|
||||
),
|
||||
condition = currencies.isNotEmpty(),
|
||||
|
|
|
|||
|
|
@ -215,7 +215,10 @@ internal class GetWalletNotificationsFactory @Inject constructor(
|
|||
tangemIcon = walletInterationIcon(userWallet),
|
||||
missingAddressesCount = currencies.count(),
|
||||
onGenerateClick = {
|
||||
clickIntents.onGenerateMissedAddressesClick(missedAddressCurrencies = currencies)
|
||||
clickIntents.onGenerateMissedAddressesClick(
|
||||
userWalletId = userWallet.walletId,
|
||||
missedAddressCurrencies = currencies,
|
||||
)
|
||||
},
|
||||
),
|
||||
condition = currencies.isNotEmpty(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue