Updated on 2026-08-14
This commit is contained in:
parent
5ec359867b
commit
68410e14b8
5 changed files with 40 additions and 29 deletions
|
|
@ -44,9 +44,9 @@ interface DeepLinksRegistry {
|
|||
|
||||
/**
|
||||
* Triggers run last launched [Intent] with deeplink handlers that can handle delayed deeplink
|
||||
* after handle [Intent] clear that and second time no intent will be handled
|
||||
* of specific [deepLinkClass] after handle [Intent] clear that and second time no intent will be handled
|
||||
*/
|
||||
fun triggerDelayedDeeplink()
|
||||
fun triggerDelayedDeeplink(deepLinkClass: Class<out DeepLink>)
|
||||
|
||||
fun cancelDelayedDeeplink()
|
||||
}
|
||||
|
|
@ -105,16 +105,18 @@ internal class DefaultDeepLinksRegistry : DeepLinksRegistry {
|
|||
val intent = lastIntent
|
||||
val received = intent?.data ?: return
|
||||
var hasMatch = false
|
||||
registries.forEach { deepLink ->
|
||||
if (!deepLink.shouldHandleDelayed) return@forEach
|
||||
val expected = deepLink.uri.toUri()
|
||||
if (!isMatches(expected, received)) return@forEach
|
||||
hasMatch = true
|
||||
registries
|
||||
.filterIsInstance(deepLinkClass)
|
||||
.forEach { deepLink ->
|
||||
if (!deepLink.shouldHandleDelayed) return@forEach
|
||||
val expected = deepLink.uri.toUri()
|
||||
if (!isMatches(expected, received)) return@forEach
|
||||
hasMatch = true
|
||||
|
||||
val params = getParams(expected, received)
|
||||
logMatch(hasMatch, expected, received, params)
|
||||
deepLink.onReceive(params)
|
||||
}
|
||||
val params = getParams(expected, received)
|
||||
logMatch(hasMatch, expected, received, params)
|
||||
deepLink.onReceive(params)
|
||||
}
|
||||
|
||||
if (!hasMatch) {
|
||||
logMatch(hasMatch, null, received, null)
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@ import androidx.compose.runtime.Stable
|
|||
import arrow.core.getOrElse
|
||||
import com.arkivanov.decompose.router.slot.activate
|
||||
import com.arkivanov.decompose.router.slot.dismiss
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
import com.tangem.core.analytics.models.event.MainScreenAnalyticsEvent
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.deeplink.DeepLinksRegistry
|
||||
import com.tangem.core.deeplink.global.ReferralDeepLink
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.nft.FetchNFTCollectionsUseCase
|
||||
|
|
@ -82,7 +86,9 @@ internal class WalletModel @Inject constructor(
|
|||
private val analyticsEventsHandler: AnalyticsEventHandler,
|
||||
private val fetchNFTCollectionsUseCase: FetchNFTCollectionsUseCase,
|
||||
private val walletsRepository: WalletsRepository,
|
||||
private val deepLinksRegistry: DeepLinksRegistry,
|
||||
private val fetchCurrencyStatusUseCase: FetchCurrencyStatusUseCase,
|
||||
private val appRouter: AppRouter,
|
||||
val screenLifecycleProvider: ScreenLifecycleProvider,
|
||||
val innerWalletRouter: InnerWalletRouter,
|
||||
) : Model() {
|
||||
|
|
@ -223,6 +229,7 @@ internal class WalletModel @Inject constructor(
|
|||
selectedWalletAnalyticsSender.send(selectedWallet)
|
||||
}
|
||||
|
||||
addReferralDeepLink(selectedWallet)
|
||||
walletDeepLinksHandler.registerForWallet(scope = modelScope, userWallet = selectedWallet)
|
||||
}
|
||||
.flowOn(dispatchers.main)
|
||||
|
|
@ -230,6 +237,20 @@ internal class WalletModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun addReferralDeepLink(userWallet: UserWallet) {
|
||||
deepLinksRegistry.register(
|
||||
ReferralDeepLink(
|
||||
onReceive = {
|
||||
if (userWallet.cardTypesResolver.isTangemWallet()) {
|
||||
appRouter.push(
|
||||
AppRoute.ReferralProgram(userWalletId = userWallet.walletId),
|
||||
)
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// We need to update the current wallet quotes if the application was in the background for more than 10 seconds
|
||||
// and then returned to the foreground
|
||||
private fun subscribeToScreenBackgroundState() {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler
|
|||
import com.tangem.core.deeplink.DeepLink
|
||||
import com.tangem.core.deeplink.DeepLinksRegistry
|
||||
import com.tangem.core.deeplink.global.BuyCurrencyDeepLink
|
||||
import com.tangem.core.deeplink.global.ReferralDeepLink
|
||||
import com.tangem.core.deeplink.global.SellCurrencyDeepLink
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.tokens.GetCryptoCurrencyUseCase
|
||||
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
|
|
@ -56,7 +54,6 @@ internal class WalletDeepLinksHandler @Inject constructor(
|
|||
)
|
||||
|
||||
return buildList {
|
||||
addReferralDeepLink(userWallet)
|
||||
add(sellCurrencyDeepLink)
|
||||
if (onrampFeatureToggles.isFeatureEnabled || !userWallet.isMultiCurrency) {
|
||||
add(
|
||||
|
|
@ -98,18 +95,4 @@ internal class WalletDeepLinksHandler @Inject constructor(
|
|||
analyticsEventHandler.send(TokenScreenAnalyticsEvent.Bought(cryptoCurrency.symbol))
|
||||
}
|
||||
}
|
||||
|
||||
private fun MutableList<DeepLink>.addReferralDeepLink(userWallet: UserWallet) {
|
||||
add(
|
||||
ReferralDeepLink(
|
||||
onReceive = {
|
||||
if (userWallet.cardTypesResolver.isTangemWallet()) {
|
||||
router.push(
|
||||
AppRoute.ReferralProgram(userWalletId = userWallet.walletId),
|
||||
)
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package com.tangem.feature.wallet.presentation.wallet.subscribers
|
|||
|
||||
import arrow.core.getOrElse
|
||||
import com.tangem.core.deeplink.DeepLinksRegistry
|
||||
import com.tangem.core.deeplink.global.ReferralDeepLink
|
||||
import com.tangem.core.deeplink.global.SellCurrencyDeepLink
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.core.lce.Lce
|
||||
|
|
@ -114,7 +116,10 @@ internal abstract class BasicTokenListSubscriber(
|
|||
protected open suspend fun onTokenListReceived(maybeTokenList: Lce<TokenListError, TokenList>) {
|
||||
/* no-op */
|
||||
if (maybeTokenList.getOrNull(false) != null) {
|
||||
deepLinksRegistry.triggerDelayedDeeplink()
|
||||
deepLinksRegistry.triggerDelayedDeeplink(deepLinkClass = SellCurrencyDeepLink::class.java)
|
||||
}
|
||||
if (maybeTokenList.getOrNull(true) != null) {
|
||||
deepLinksRegistry.triggerDelayedDeeplink(deepLinkClass = ReferralDeepLink::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue