Updated on 2026-08-14

This commit is contained in:
Tangem 2023-07-05 11:21:21 +03:00
commit 06a81d009f
3 changed files with 17 additions and 2 deletions

View file

@ -268,6 +268,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), SafeStoreSubscriber<W
private fun refreshWalletData() {
Analytics.send(Portfolio.Refreshed())
store.dispatch(WalletAction.LoadData.Refresh)
learn2earnViewModel.onMainScreenRefreshed()
}
private fun showWarningsIfPresent(warnings: List<WarningMessage>) {

View file

@ -48,8 +48,18 @@ class DefaultLearn2earnInteractor(
override suspend fun isNeedToShowViewOnMainScreen(): Boolean {
if (!promotionIsActive()) return false
val response = repository.validate(userWalletManager.getWalletId())
return response.valid == true
val promoCode = repository.getUserData().promoCode
val userWalletId = userWalletManager.getWalletId()
return if (promoCode == null) {
val response = repository.validate(userWalletId)
response.valid == true
} else {
val response = repository.validateCode(userWalletId, promoCode)
when (val error = response.error?.toDomainError()) {
null -> response.valid == true
else -> error !is PromotionError.CodeWasNotAppliedInShop
}
}
}
override fun isUserRegisteredInPromotion(): Boolean {

View file

@ -45,6 +45,10 @@ class Learn2earnViewModel @Inject constructor(
updateMainScreenViews()
}
fun onMainScreenRefreshed() {
updateMainScreenViews()
}
private fun updateMainScreenViews() {
viewModelScope.launch(dispatchers.io) {
if (interactor.isNeedToShowViewOnMainScreen()) {