Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-19 13:51:48 +03:00
parent c1b426ef9f
commit 73b80b5ef9
7 changed files with 108 additions and 74 deletions

View file

@ -92,21 +92,24 @@ private fun handleAction(action: Action, appState: () -> AppState?) {
scope.launch { exchangeManager.update() }
}
is GlobalAction.FetchUserCountry -> {
scope.launch {
// TODO("After adding DI") get dependencies by DI
runCatching { store.state.featureRepositoryProvider.homeRepository.getUserCountryCode() }
.onSuccess {
store.dispatchOnMain(
GlobalAction.FetchUserCountry.Success(countryCode = it.code.lowercase()),
)
}
.onFailure {
store.dispatchOnMain(
GlobalAction.FetchUserCountry.Success(
countryCode = Locale.getDefault().country.lowercase(),
),
)
}
val homeFeatureToggles = store.inject(DaggerGraphState::homeFeatureToggles)
if (!homeFeatureToggles.isMigrateUserCountryCodeEnabled) {
scope.launch {
runCatching { store.state.featureRepositoryProvider.homeRepository.getUserCountryCode() }
.onSuccess {
store.dispatchOnMain(
GlobalAction.FetchUserCountry.Success(countryCode = it.code.lowercase()),
)
}
.onFailure {
store.dispatchOnMain(
GlobalAction.FetchUserCountry.Success(
countryCode = Locale.getDefault().country.lowercase(),
),
)
}
}
}
}
}

View file

@ -23,6 +23,7 @@ data class GlobalState(
val scanCardFailsCounter: Int = 0,
val dialog: StateDialog? = null,
val exchangeManager: CurrencyExchangeManager = CurrencyExchangeManager.dummy(),
@Deprecated("Use GetUserCountryCodeUseCase instead")
val userCountryCode: String? = null,
val appThemeMode: AppThemeMode = AppThemeMode.DEFAULT,
) : StateType