diff --git a/app/src/main/java/com/tangem/tap/MainActivity.kt b/app/src/main/java/com/tangem/tap/MainActivity.kt index 1fabef9308..7e7b505cb9 100644 --- a/app/src/main/java/com/tangem/tap/MainActivity.kt +++ b/app/src/main/java/com/tangem/tap/MainActivity.kt @@ -26,7 +26,6 @@ import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import arrow.core.getOrElse import com.tangem.common.routing.AppRoute -import com.tangem.common.routing.RoutingFeatureToggle import com.tangem.common.routing.entity.SerializableIntent import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.decompose.context.AppComponentContext @@ -169,9 +168,6 @@ class MainActivity : AppCompatActivity(), ActivityResultCallbackHolder { @Inject internal lateinit var defaultDeviceFlipDetector: DefaultDeviceFlipDetector - @Inject - internal lateinit var routingFeatureToggle: RoutingFeatureToggle - @Inject internal lateinit var deeplinkFactory: DeepLinkFactory @@ -236,11 +232,6 @@ class MainActivity : AppCompatActivity(), ActivityResultCallbackHolder { sendStakingUnsubmittedHashes() checkGoogleServicesAvailability() - if (routingFeatureToggle.isDeepLinkNavigationEnabled.not() && intent != null && savedInstanceState == null) { - // handle intent only on start, not on recreate - handleDeepLink(intent = intent, isFromOnNewIntent = false) - } - lifecycle.addObserver(WindowObscurationObserver) lifecycle.addObserver(defaultDeviceFlipDetector) @@ -477,7 +468,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallbackHolder { } } - if (routingFeatureToggle.isDeepLinkNavigationEnabled && intent != null) { + if (intent != null) { handleDeepLink(intent = intent, isFromOnNewIntent = false) } @@ -485,26 +476,22 @@ class MainActivity : AppCompatActivity(), ActivityResultCallbackHolder { } private fun handleDeepLink(intent: Intent, isFromOnNewIntent: Boolean) { - if (routingFeatureToggle.isDeepLinkNavigationEnabled) { - val deepLinkExtras = intent.getStringExtra(DEEPLINK_KEY)?.toUri() - val webLink = intent.getStringExtra(WEBLINK_KEY) + val deepLinkExtras = intent.getStringExtra(DEEPLINK_KEY)?.toUri() + val webLink = intent.getStringExtra(WEBLINK_KEY) - val receivedDeepLink = intent.data ?: deepLinkExtras + val receivedDeepLink = intent.data ?: deepLinkExtras - when { - receivedDeepLink != null -> { - deeplinkFactory.handleDeeplink( - deeplinkUri = receivedDeepLink, - coroutineScope = lifecycleScope, - isFromOnNewIntent = isFromOnNewIntent, - ) - } - webLink?.uriValidate() == true -> { - urlOpener.openUrl(webLink) - } + when { + receivedDeepLink != null -> { + deeplinkFactory.handleDeeplink( + deeplinkUri = receivedDeepLink, + coroutineScope = lifecycleScope, + isFromOnNewIntent = isFromOnNewIntent, + ) + } + webLink?.uriValidate() == true -> { + urlOpener.openUrl(webLink) } - } else { - deepLinksRegistry.launch(intent) } } diff --git a/app/src/main/java/com/tangem/tap/di/routing/AppRouterModule.kt b/app/src/main/java/com/tangem/tap/di/routing/AppRouterModule.kt index a95acf5cd6..3bfc0b3a44 100644 --- a/app/src/main/java/com/tangem/tap/di/routing/AppRouterModule.kt +++ b/app/src/main/java/com/tangem/tap/di/routing/AppRouterModule.kt @@ -1,9 +1,7 @@ package com.tangem.tap.di.routing import com.tangem.common.routing.AppRouter -import com.tangem.common.routing.RoutingFeatureToggle import com.tangem.core.analytics.api.AnalyticsExceptionHandler -import com.tangem.core.configtoggle.feature.FeatureTogglesManager import com.tangem.tap.routing.ProxyAppRouter import com.tangem.tap.routing.configurator.AppRouterConfig import com.tangem.tap.routing.configurator.MutableAppRouterConfig @@ -33,10 +31,4 @@ internal object AppRouterModule { @Provides @Singleton fun provideAppRouterConfigurator(): AppRouterConfig = MutableAppRouterConfig() - - @Provides - @Singleton - fun provideRoutingFeatureToggle(featureTogglesManager: FeatureTogglesManager): RoutingFeatureToggle { - return RoutingFeatureToggle(featureTogglesManager) - } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/main/MainViewModel.kt b/app/src/main/java/com/tangem/tap/features/main/MainViewModel.kt index 22b4dd8a31..9d3861f1db 100644 --- a/app/src/main/java/com/tangem/tap/features/main/MainViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/main/MainViewModel.kt @@ -4,13 +4,11 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.tangem.blockchainsdk.BlockchainSDKFactory import com.tangem.common.keyboard.KeyboardValidator -import com.tangem.common.routing.RoutingFeatureToggle import com.tangem.core.analytics.Analytics import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.analytics.models.event.TechAnalyticsEvent import com.tangem.core.decompose.di.GlobalUiMessageSender import com.tangem.core.decompose.ui.UiMessageSender -import com.tangem.core.deeplink.DeepLinksRegistry import com.tangem.core.ui.R import com.tangem.core.ui.coil.ImagePreloader import com.tangem.core.ui.extensions.resourceReference @@ -47,7 +45,6 @@ import com.tangem.domain.wallets.usecase.AssociateWalletsWithApplicationIdUseCas import com.tangem.domain.wallets.usecase.GetSavedWalletChangesUseCase import com.tangem.domain.wallets.usecase.UpdateRemoteWalletsInfoUseCase import com.tangem.feature.swap.analytics.StoriesEvents -import com.tangem.features.onramp.deeplink.OnrampDeepLink import com.tangem.tap.common.extensions.setContext import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.features.onboarding.products.wallet.redux.BackupDialog @@ -86,8 +83,6 @@ internal class MainViewModel @Inject constructor( private val imagePreloader: ImagePreloader, private val fetchHotCryptoUseCase: FetchHotCryptoUseCase, private val onboardingRepository: OnboardingRepository, - private val deepLinksRegistry: DeepLinksRegistry, - private val onrampDeepLinkFactory: OnrampDeepLink.Factory, private val notificationsToggles: NotificationsFeatureToggles, private val getApplicationIdUseCase: GetApplicationIdUseCase, private val subscribeOnWalletsUseCase: GetSavedWalletChangesUseCase, @@ -98,7 +93,6 @@ internal class MainViewModel @Inject constructor( private val multiQuoteUpdater: MultiQuoteUpdater, private val appStateHolder: AppStateHolder, private val environmentConfigStorage: EnvironmentConfigStorage, - routingFeatureToggle: RoutingFeatureToggle, getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase, ) : ViewModel() { @@ -141,10 +135,6 @@ internal class MainViewModel @Inject constructor( sendKeyboardIdentifierEvent() preloadImages() - - if (!routingFeatureToggle.isDeepLinkNavigationEnabled) { - initializeDeepLinks() - } } override fun onCleared() { @@ -423,7 +413,7 @@ internal class MainViewModel @Inject constructor( } } } catch (ex: Exception) { - Timber.e(ex.message) + Timber.e(ex) analyticsEventHandler.send( StoriesEvents.Error( type = StoryContentIds.STORY_FIRST_TIME_SWAP.analyticType, @@ -432,10 +422,6 @@ internal class MainViewModel @Inject constructor( } } - private fun initializeDeepLinks() { - deepLinksRegistry.register(onrampDeepLinkFactory.create(viewModelScope)) - } - private suspend fun initPushNotifications() { if (notificationsToggles.isNotificationsEnabled) { getApplicationIdUseCase().onRight { applicationId -> diff --git a/common/routing/src/main/kotlin/com/tangem/common/routing/RoutingFeatureToggle.kt b/common/routing/src/main/kotlin/com/tangem/common/routing/RoutingFeatureToggle.kt deleted file mode 100644 index 9574ce9bf3..0000000000 --- a/common/routing/src/main/kotlin/com/tangem/common/routing/RoutingFeatureToggle.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.tangem.common.routing - -import com.tangem.core.configtoggle.feature.FeatureTogglesManager - -class RoutingFeatureToggle( - private val featureTogglesManager: FeatureTogglesManager, -) { - - val isDeepLinkNavigationEnabled: Boolean - get() = featureTogglesManager.isFeatureEnabled(name = "DEEPLINK_NAVIGATION_ENABLED") -} \ No newline at end of file diff --git a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json index aba93f0e66..caa2e3d796 100644 --- a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json +++ b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json @@ -27,10 +27,6 @@ "name": "STAKING_LOADING_REFACTORING_ENABLED", "version": "5.25.0" }, - { - "name": "DEEPLINK_NAVIGATION_ENABLED", - "version": "5.25.0" - }, { "name": "PUSH_NOTIFICATIONS_ENABLED", "version": "undefined" diff --git a/core/deep-links/global/src/main/kotlin/com/tangem/core/deeplink/global/ReferralDeepLink.kt b/core/deep-links/global/src/main/kotlin/com/tangem/core/deeplink/global/ReferralDeepLink.kt deleted file mode 100644 index 5dcf6211d5..0000000000 --- a/core/deep-links/global/src/main/kotlin/com/tangem/core/deeplink/global/ReferralDeepLink.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.tangem.core.deeplink.global - -import com.tangem.core.deeplink.DeepLink - -@Deprecated("Use ReferralDeepLinkHandler") -class ReferralDeepLink( - val onReceive: () -> Unit, -) : DeepLink(shouldHandleDelayed = true) { - override val uri: String = "tangem://referral" - - override fun onReceive(params: Map) { - onReceive() - } -} \ No newline at end of file diff --git a/core/deep-links/global/src/main/kotlin/com/tangem/core/deeplink/global/SellCurrencyDeepLink.kt b/core/deep-links/global/src/main/kotlin/com/tangem/core/deeplink/global/SellCurrencyDeepLink.kt deleted file mode 100644 index c3ac0e7faa..0000000000 --- a/core/deep-links/global/src/main/kotlin/com/tangem/core/deeplink/global/SellCurrencyDeepLink.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.tangem.core.deeplink.global - -import com.tangem.core.deeplink.DeepLink - -@Deprecated("Use SellDeepLinkHandler") -class SellCurrencyDeepLink( - val onReceive: (data: Data) -> Unit, - shouldHandleDelayed: Boolean, -) : DeepLink(shouldHandleDelayed) { - - override val uri: String = "tangem://redirect_sell" - - override fun onReceive(params: Map) { - val data = Data( - transactionId = params["transactionId"] ?: return, - baseCurrencyAmount = params["baseCurrencyAmount"] ?: return, - depositWalletAddress = params["depositWalletAddress"] ?: return, - currencyId = params["currency_id"] ?: return, - depositWalletAddressTag = params["depositWalletAddressTag"], - ) - - onReceive(data) - } - - data class Data( - val transactionId: String, - val baseCurrencyAmount: String, - val depositWalletAddress: String, - val currencyId: String, - val depositWalletAddressTag: String?, - ) -} \ No newline at end of file diff --git a/core/deep-links/src/main/kotlin/com/tangem/core/deeplink/utils/AppComponentContextExtensions.kt b/core/deep-links/src/main/kotlin/com/tangem/core/deeplink/utils/AppComponentContextExtensions.kt deleted file mode 100644 index 594b8305ca..0000000000 --- a/core/deep-links/src/main/kotlin/com/tangem/core/deeplink/utils/AppComponentContextExtensions.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.tangem.core.deeplink.utils - -import com.arkivanov.essenty.lifecycle.subscribe -import com.tangem.core.decompose.context.AppComponentContext -import com.tangem.core.deeplink.DeepLink -import com.tangem.core.deeplink.DeepLinksRegistry - -fun AppComponentContext.registerDeepLinks(registry: DeepLinksRegistry, vararg deepLinks: DeepLink) { - registerDeepLinks(registry, deepLinks.toList()) -} - -fun AppComponentContext.registerDeepLinks(registry: DeepLinksRegistry, deepLinks: Collection) { - lifecycle.subscribe( - onCreate = { - registry.register(deepLinks) - }, - onDestroy = { - registry.unregister(deepLinks) - }, - ) -} \ No newline at end of file diff --git a/features/onramp/api/src/main/kotlin/com/tangem/features/onramp/deeplink/OnrampDeepLink.kt b/features/onramp/api/src/main/kotlin/com/tangem/features/onramp/deeplink/OnrampDeepLink.kt deleted file mode 100644 index 8a45fc89ef..0000000000 --- a/features/onramp/api/src/main/kotlin/com/tangem/features/onramp/deeplink/OnrampDeepLink.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.tangem.features.onramp.deeplink - -import com.tangem.core.deeplink.DeepLink -import kotlinx.coroutines.CoroutineScope - -@Deprecated("Use OnrampDeepLinkHandler") -abstract class OnrampDeepLink : DeepLink() { - override val uri = "tangem://onramp" - - interface Factory { - fun create(coroutineScope: CoroutineScope): OnrampDeepLink - } -} - -interface OnrampDeepLinkHandler { - - interface Factory { - fun create(coroutineScope: CoroutineScope, queryParams: Map): OnrampDeepLinkHandler - } -} \ No newline at end of file diff --git a/features/onramp/api/src/main/kotlin/com/tangem/features/onramp/deeplink/OnrampDeepLinkHandler.kt b/features/onramp/api/src/main/kotlin/com/tangem/features/onramp/deeplink/OnrampDeepLinkHandler.kt new file mode 100644 index 0000000000..35f5e06190 --- /dev/null +++ b/features/onramp/api/src/main/kotlin/com/tangem/features/onramp/deeplink/OnrampDeepLinkHandler.kt @@ -0,0 +1,10 @@ +package com.tangem.features.onramp.deeplink + +import kotlinx.coroutines.CoroutineScope + +interface OnrampDeepLinkHandler { + + interface Factory { + fun create(coroutineScope: CoroutineScope, queryParams: Map): OnrampDeepLinkHandler + } +} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/deeplink/DefaultOnrampDeepLink.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/deeplink/DefaultOnrampDeepLink.kt deleted file mode 100644 index a7edc4cbf5..0000000000 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/deeplink/DefaultOnrampDeepLink.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.tangem.features.onramp.deeplink - -import com.tangem.common.routing.AppRoute -import com.tangem.common.routing.AppRouter -import com.tangem.features.onramp.success.OnrampSuccessScreenTrigger -import dagger.assisted.Assisted -import dagger.assisted.AssistedFactory -import dagger.assisted.AssistedInject -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch - -internal class DefaultOnrampDeepLink @AssistedInject constructor( - private val appRouter: AppRouter, - private val onrampSuccessScreenTrigger: OnrampSuccessScreenTrigger, - @Assisted private val scope: CoroutineScope, -) : OnrampDeepLink() { - - override fun onReceive(params: Map) { - val txId = params[TX_ID_KEY] - val result = OnrampRedirectResult.getResult(params[RESULT_KEY]) - - when { - !txId.isNullOrEmpty() -> { - // finish current onramp flow and show onramp success screen - val replaceOnrampScreens = appRouter.stack - .filterNot { it is AppRoute.Onramp } - .toMutableList() - replaceOnrampScreens.add(AppRoute.OnrampSuccess(txId)) - appRouter.replaceAll(*replaceOnrampScreens.toTypedArray()) - } - result != OnrampRedirectResult.Unknown -> { - scope.launch { - onrampSuccessScreenTrigger.triggerOnrampSuccess(result == OnrampRedirectResult.Success) - } - } - } - } - - @AssistedFactory - interface Factory : OnrampDeepLink.Factory { - override fun create(coroutineScope: CoroutineScope): DefaultOnrampDeepLink - } - - private companion object { - const val TX_ID_KEY = "tx_id" - const val RESULT_KEY = "result" - } -} \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/deeplink/di/OnrampDeeplinkModule.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/deeplink/di/OnrampDeeplinkModule.kt index fafbf571a6..48b413740f 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/deeplink/di/OnrampDeeplinkModule.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/deeplink/di/OnrampDeeplinkModule.kt @@ -11,10 +11,6 @@ import javax.inject.Singleton @InstallIn(SingletonComponent::class) internal interface OnrampDeeplinkModule { - @Binds - @Singleton - fun bindFactory(impl: DefaultOnrampDeepLink.Factory): OnrampDeepLink.Factory - @Binds @Singleton fun bindOnrampDeepLinkHandlerFactory(impl: DefaultOnrampDeepLinkHandler.Factory): OnrampDeepLinkHandler.Factory diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index 4891a75416..327c2b8470 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -4,16 +4,11 @@ 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.common.routing.RoutingFeatureToggle 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.ObserveAndClearNFTCacheIfNeedUseCase @@ -27,7 +22,6 @@ import com.tangem.domain.wallets.models.isMultiCurrency import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase import com.tangem.domain.wallets.usecase.GetWalletsUseCase import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents -import com.tangem.feature.wallet.presentation.deeplink.WalletDeepLinksHandler import com.tangem.feature.wallet.presentation.router.InnerWalletRouter import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent import com.tangem.feature.wallet.presentation.wallet.analytics.utils.SelectedWalletAnalyticsSender @@ -73,7 +67,6 @@ internal class WalletModel @Inject constructor( private val isWalletsScrollPreviewEnabled: IsWalletsScrollPreviewEnabled, private val getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase, private val selectedWalletAnalyticsSender: SelectedWalletAnalyticsSender, - private val walletDeepLinksHandler: WalletDeepLinksHandler, private val walletNameMigrationUseCase: WalletNameMigrationUseCase, private val refreshMultiCurrencyWalletQuotesUseCase: RefreshMultiCurrencyWalletQuotesUseCase, private val shouldAskPermissionUseCase: ShouldAskPermissionUseCase, @@ -81,12 +74,9 @@ internal class WalletModel @Inject constructor( private val tokenListStore: MultiWalletTokenListStore, private val onrampStatusFactory: OnrampStatusFactory, private val analyticsEventsHandler: AnalyticsEventHandler, - private val deepLinksRegistry: DeepLinksRegistry, private val fetchCurrencyStatusUseCase: FetchCurrencyStatusUseCase, private val walletContentFetcher: WalletContentFetcher, private val tokensFeatureToggles: TokensFeatureToggles, - private val appRouter: AppRouter, - private val routingFeatureToggle: RoutingFeatureToggle, private val observeAndClearNFTCacheIfNeedUseCase: ObserveAndClearNFTCacheIfNeedUseCase, private val walletDeepLinkActionListener: WalletDeepLinkActionListener, val screenLifecycleProvider: ScreenLifecycleProvider, @@ -241,12 +231,6 @@ internal class WalletModel @Inject constructor( selectedWalletAnalyticsSender.send(selectedWallet) } - if (!routingFeatureToggle.isDeepLinkNavigationEnabled) { - // Registering here, because `WalletDeepLinksHandler` unregisters deeplink when scope is cancelled - // This is temporary solution, will be removed with complete deeplink navigation overhaul - addReferralDeepLink(selectedWallet) - walletDeepLinksHandler.registerForWallet(scope = modelScope, userWallet = selectedWallet) - } subscribeOnExpressTransactionsUpdates(selectedWallet) observeAndClearNFTCacheIfNeedUseCase(selectedWallet) } @@ -268,20 +252,6 @@ internal class WalletModel @Inject constructor( } } - private fun addReferralDeepLink(userWallet: UserWallet) { - deepLinksRegistry.register( - ReferralDeepLink( - onReceive = { - if (userWallet !is UserWallet.Cold || 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() { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/deeplink/WalletDeepLinksHandler.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/deeplink/WalletDeepLinksHandler.kt deleted file mode 100644 index 987fcedb41..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/deeplink/WalletDeepLinksHandler.kt +++ /dev/null @@ -1,73 +0,0 @@ -package com.tangem.feature.wallet.presentation.deeplink - -import com.tangem.common.routing.AppRoute -import com.tangem.common.routing.AppRouter -import com.tangem.core.deeplink.DeepLink -import com.tangem.core.deeplink.DeepLinksRegistry -import com.tangem.core.deeplink.global.SellCurrencyDeepLink -import com.tangem.domain.tokens.GetCryptoCurrencyUseCase -import com.tangem.domain.wallets.models.UserWallet -import com.tangem.domain.wallets.models.UserWalletId -import com.tangem.utils.coroutines.launchOnCancellation -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch -import timber.log.Timber -import javax.inject.Inject - -@Suppress("LongParameterList") -internal class WalletDeepLinksHandler @Inject constructor( - private val deepLinksRegistry: DeepLinksRegistry, - private val getCryptoCurrencyUseCase: GetCryptoCurrencyUseCase, - private val router: AppRouter, -) { - - private var deepLinksMap = mutableMapOf>() - - fun registerForWallet(scope: CoroutineScope, userWallet: UserWallet) { - val deepLinks = deepLinksMap.getOrPut(userWallet.walletId) { - getDeepLinks(userWallet, scope) - } - deepLinksRegistry.unregisterByIds(deepLinks.map { it.id }) - deepLinksRegistry.register(deepLinks = deepLinks) - - // When navigation to another screen scope is Cancelled and deeplinks are hot handled - scope.launchOnCancellation { - deepLinksRegistry.unregister(deepLinks) - } - } - - private fun getDeepLinks(userWallet: UserWallet, scope: CoroutineScope): List { - val sellCurrencyDeepLink = SellCurrencyDeepLink( - onReceive = { data -> - scope.launch { - onSellCurrencyDeepLink(userWallet, data) - } - }, - shouldHandleDelayed = true, - ) - - return buildList { - add(sellCurrencyDeepLink) - } - } - - private suspend fun onSellCurrencyDeepLink(userWallet: UserWallet, data: SellCurrencyDeepLink.Data) { - val cryptoCurrency = getCryptoCurrencyUseCase(userWallet, data.currencyId).getOrNull() - - if (cryptoCurrency == null) { - Timber.e("onSellCurrencyDeepLink cryptoCurrency is null") - return - } - - val route = AppRoute.Send( - currency = cryptoCurrency, - userWalletId = userWallet.walletId, - transactionId = data.transactionId, - destinationAddress = data.depositWalletAddress, - amount = data.baseCurrencyAmount, - tag = data.depositWalletAddressTag, - ) - - router.push(route) - } -} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoader.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoader.kt index 6a6bd30b0b..f06e06fe21 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoader.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoader.kt @@ -1,8 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.loaders.implementors -import com.tangem.common.routing.RoutingFeatureToggle import com.tangem.core.decompose.di.ModelScoped -import com.tangem.core.deeplink.DeepLinksRegistry import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.nft.GetNFTCollectionsUseCase import com.tangem.domain.promo.GetStoryContentUseCase @@ -40,10 +38,8 @@ internal class MultiWalletContentLoader( private val runPolkadotAccountHealthCheckUseCase: RunPolkadotAccountHealthCheckUseCase, private val shouldSaveUserWalletsUseCase: ShouldSaveUserWalletsUseCase, private val getStoryContentUseCase: GetStoryContentUseCase, - private val deepLinksRegistry: DeepLinksRegistry, private val walletsRepository: WalletsRepository, private val currenciesRepository: CurrenciesRepository, - private val routingFeatureToggle: RoutingFeatureToggle, ) : WalletContentLoader(id = userWallet.walletId) { override fun create(): List { @@ -58,8 +54,6 @@ internal class MultiWalletContentLoader( getSelectedAppCurrencyUseCase = getSelectedAppCurrencyUseCase, applyTokenListSortingUseCase = applyTokenListSortingUseCase, runPolkadotAccountHealthCheckUseCase = runPolkadotAccountHealthCheckUseCase, - deepLinksRegistry = deepLinksRegistry, - routingFeatureToggle = routingFeatureToggle, ).let(::add) WalletNFTListSubscriber( diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoaderFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoaderFactory.kt index 71d7be251c..49216f3aac 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoaderFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/MultiWalletContentLoaderFactory.kt @@ -1,8 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.loaders.implementors -import com.tangem.common.routing.RoutingFeatureToggle import com.tangem.core.decompose.di.ModelScoped -import com.tangem.core.deeplink.DeepLinksRegistry import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.nft.GetNFTCollectionsUseCase import com.tangem.domain.promo.GetStoryContentUseCase @@ -37,10 +35,8 @@ internal class MultiWalletContentLoaderFactory @Inject constructor( private val runPolkadotAccountHealthCheckUseCase: RunPolkadotAccountHealthCheckUseCase, private val shouldSaveUserWalletsUseCase: ShouldSaveUserWalletsUseCase, private val getStoryContentUseCase: GetStoryContentUseCase, - private val deepLinksRegistry: DeepLinksRegistry, private val walletsRepository: WalletsRepository, private val getNFTCollectionsUseCase: GetNFTCollectionsUseCase, - private val routingFeatureToggle: RoutingFeatureToggle, private val currenciesRepository: CurrenciesRepository, ) { @@ -60,10 +56,8 @@ internal class MultiWalletContentLoaderFactory @Inject constructor( runPolkadotAccountHealthCheckUseCase = runPolkadotAccountHealthCheckUseCase, getStoryContentUseCase = getStoryContentUseCase, shouldSaveUserWalletsUseCase = shouldSaveUserWalletsUseCase, - deepLinksRegistry = deepLinksRegistry, walletsRepository = walletsRepository, getNFTCollectionsUseCase = getNFTCollectionsUseCase, - routingFeatureToggle = routingFeatureToggle, currenciesRepository = currenciesRepository, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoader.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoader.kt index 811b27a4f4..29f8ef2cae 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoader.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoader.kt @@ -1,7 +1,5 @@ package com.tangem.feature.wallet.presentation.wallet.loaders.implementors -import com.tangem.common.routing.RoutingFeatureToggle -import com.tangem.core.deeplink.DeepLinksRegistry import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.promo.GetStoryContentUseCase import com.tangem.domain.tokens.RunPolkadotAccountHealthCheckUseCase @@ -32,8 +30,6 @@ internal class SingleWalletWithTokenContentLoader( private val runPolkadotAccountHealthCheckUseCase: RunPolkadotAccountHealthCheckUseCase, private val shouldSaveUserWalletsUseCase: ShouldSaveUserWalletsUseCase, private val getStoryContentUseCase: GetStoryContentUseCase, - private val deepLinksRegistry: DeepLinksRegistry, - private val routingFeatureToggle: RoutingFeatureToggle, ) : WalletContentLoader(id = userWallet.walletId) { override fun create(): List { @@ -47,8 +43,6 @@ internal class SingleWalletWithTokenContentLoader( tokenListStore = tokenListStore, getSelectedAppCurrencyUseCase = getSelectedAppCurrencyUseCase, runPolkadotAccountHealthCheckUseCase = runPolkadotAccountHealthCheckUseCase, - deepLinksRegistry = deepLinksRegistry, - routingFeatureToggle = routingFeatureToggle, ).let(::add) MultiWalletWarningsSubscriber( userWallet = userWallet, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoaderFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoaderFactory.kt index 8f7e5cb7cf..04bdd97c7e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoaderFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/implementors/SingleWalletWithTokenContentLoaderFactory.kt @@ -1,13 +1,12 @@ package com.tangem.feature.wallet.presentation.wallet.loaders.implementors -import com.tangem.common.routing.RoutingFeatureToggle import com.tangem.core.decompose.di.ModelScoped -import com.tangem.core.deeplink.DeepLinksRegistry import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.promo.GetStoryContentUseCase import com.tangem.domain.tokens.RunPolkadotAccountHealthCheckUseCase import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.usecase.ShouldSaveUserWalletsUseCase +import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsSingleEventSender @@ -15,7 +14,6 @@ import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarnin import com.tangem.feature.wallet.presentation.wallet.domain.MultiWalletTokenListStore import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController -import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents import javax.inject.Inject // TODO: Refactor @@ -33,8 +31,6 @@ internal class SingleWalletWithTokenContentLoaderFactory @Inject constructor( private val runPolkadotAccountHealthCheckUseCase: RunPolkadotAccountHealthCheckUseCase, private val shouldSaveUserWalletsUseCase: ShouldSaveUserWalletsUseCase, private val getStoryContentUseCase: GetStoryContentUseCase, - private val deepLinksRegistry: DeepLinksRegistry, - private val routingFeatureToggle: RoutingFeatureToggle, ) { fun create(userWallet: UserWallet, clickIntents: WalletClickIntents): SingleWalletWithTokenContentLoader { @@ -52,8 +48,6 @@ internal class SingleWalletWithTokenContentLoaderFactory @Inject constructor( runPolkadotAccountHealthCheckUseCase = runPolkadotAccountHealthCheckUseCase, getStoryContentUseCase = getStoryContentUseCase, shouldSaveUserWalletsUseCase = shouldSaveUserWalletsUseCase, - deepLinksRegistry = deepLinksRegistry, - routingFeatureToggle = routingFeatureToggle, ) } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicTokenListSubscriber.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicTokenListSubscriber.kt index 796767b539..56ca8030c6 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicTokenListSubscriber.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicTokenListSubscriber.kt @@ -1,10 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.subscribers import arrow.core.getOrElse -import com.tangem.common.routing.RoutingFeatureToggle -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 @@ -39,8 +35,6 @@ internal abstract class BasicTokenListSubscriber( private val walletWithFundsChecker: WalletWithFundsChecker, private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase, private val runPolkadotAccountHealthCheckUseCase: RunPolkadotAccountHealthCheckUseCase, - private val deepLinksRegistry: DeepLinksRegistry, - private val routingFeatureToggle: RoutingFeatureToggle, ) : WalletSubscriber() { private val sendAnalyticsJobHolder = JobHolder() @@ -48,6 +42,8 @@ internal abstract class BasicTokenListSubscriber( protected abstract fun tokenListFlow(coroutineScope: CoroutineScope): LceFlow + protected abstract suspend fun onTokenListReceived(maybeTokenList: Lce) + override fun create(coroutineScope: CoroutineScope): Flow<*> { return combine( flow = tokenListFlow(coroutineScope) @@ -114,21 +110,6 @@ internal abstract class BasicTokenListSubscriber( } } - protected open suspend fun onTokenListReceived(maybeTokenList: Lce) { - if (!routingFeatureToggle.isDeepLinkNavigationEnabled) { - /* no-op */ - // Handling sell deeplink requires full content in order to correctly open Send screen - if (maybeTokenList.getOrNull(false) != null) { - deepLinksRegistry.triggerDelayedDeeplink(deepLinkClass = SellCurrencyDeepLink::class.java) - } - // Handling referral deeplink requires only selected wallet to be loaded - // This is temporary solution, will be removed with complete deeplink navigation overhaul - if (maybeTokenList.getOrNull(true) != null) { - deepLinksRegistry.triggerDelayedDeeplink(deepLinkClass = ReferralDeepLink::class.java) - } - } - } - private suspend fun sendTokenListAnalytics(maybeTokenList: Lce) { val displayedState = stateHolder.getWalletStateIfSelected(userWallet.walletId) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/MultiWalletTokenListSubscriber.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/MultiWalletTokenListSubscriber.kt index fafdfc910f..d236857b9f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/MultiWalletTokenListSubscriber.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/MultiWalletTokenListSubscriber.kt @@ -1,7 +1,5 @@ package com.tangem.feature.wallet.presentation.wallet.subscribers -import com.tangem.common.routing.RoutingFeatureToggle -import com.tangem.core.deeplink.DeepLinksRegistry import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.core.lce.Lce import com.tangem.domain.core.lce.LceFlow @@ -30,8 +28,6 @@ internal class MultiWalletTokenListSubscriber( walletWithFundsChecker: WalletWithFundsChecker, getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase, runPolkadotAccountHealthCheckUseCase: RunPolkadotAccountHealthCheckUseCase, - deepLinksRegistry: DeepLinksRegistry, - routingFeatureToggle: RoutingFeatureToggle, ) : BasicTokenListSubscriber( userWallet = userWallet, stateHolder = stateHolder, @@ -40,8 +36,6 @@ internal class MultiWalletTokenListSubscriber( walletWithFundsChecker = walletWithFundsChecker, getSelectedAppCurrencyUseCase = getSelectedAppCurrencyUseCase, runPolkadotAccountHealthCheckUseCase = runPolkadotAccountHealthCheckUseCase, - deepLinksRegistry = deepLinksRegistry, - routingFeatureToggle = routingFeatureToggle, ) { override fun tokenListFlow(coroutineScope: CoroutineScope): LceFlow { @@ -52,7 +46,6 @@ internal class MultiWalletTokenListSubscriber( override suspend fun onTokenListReceived(maybeTokenList: Lce) { updateSortingIfNeeded(maybeTokenList) - super.onTokenListReceived(maybeTokenList) } private suspend fun updateSortingIfNeeded(maybeTokenList: Lce<*, TokenList>) { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/SingleWalletWithTokenListSubscriber.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/SingleWalletWithTokenListSubscriber.kt index 467d739893..13ebe5e40c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/SingleWalletWithTokenListSubscriber.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/SingleWalletWithTokenListSubscriber.kt @@ -1,8 +1,7 @@ package com.tangem.feature.wallet.presentation.wallet.subscribers -import com.tangem.common.routing.RoutingFeatureToggle -import com.tangem.core.deeplink.DeepLinksRegistry import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase +import com.tangem.domain.core.lce.Lce import com.tangem.domain.core.lce.LceFlow import com.tangem.domain.tokens.RunPolkadotAccountHealthCheckUseCase import com.tangem.domain.tokens.error.TokenListError @@ -25,8 +24,6 @@ internal class SingleWalletWithTokenListSubscriber( walletWithFundsChecker: WalletWithFundsChecker, getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase, runPolkadotAccountHealthCheckUseCase: RunPolkadotAccountHealthCheckUseCase, - deepLinksRegistry: DeepLinksRegistry, - routingFeatureToggle: RoutingFeatureToggle, ) : BasicTokenListSubscriber( userWallet = userWallet, stateHolder = stateHolder, @@ -35,8 +32,6 @@ internal class SingleWalletWithTokenListSubscriber( walletWithFundsChecker = walletWithFundsChecker, getSelectedAppCurrencyUseCase = getSelectedAppCurrencyUseCase, runPolkadotAccountHealthCheckUseCase = runPolkadotAccountHealthCheckUseCase, - deepLinksRegistry = deepLinksRegistry, - routingFeatureToggle = routingFeatureToggle, ) { override fun tokenListFlow(coroutineScope: CoroutineScope): LceFlow { @@ -44,4 +39,6 @@ internal class SingleWalletWithTokenListSubscriber( return tokenListStore.getOrThrow(userWallet.walletId) } + + override suspend fun onTokenListReceived(maybeTokenList: Lce) = Unit } \ No newline at end of file