From f10f44e7b03e561b2d0f64e30e7f03e7809e8f0c Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 11 Jul 2025 18:26:51 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../SendNotificationsUpdateListener.kt | 12 +++++++++++ .../SendNotificationsUpdateTrigger.kt | 11 ++++++++++ .../v2/send/confirm/model/SendConfirmModel.kt | 8 ++++--- .../confirm/model/NFTSendConfirmModel.kt | 8 ++++--- ...t => DefaultNotificationsUpdateTrigger.kt} | 21 +++++-------------- .../notifications/di/NotificationsModule.kt | 17 ++++++++------- .../notifications/model/NotificationsModel.kt | 8 ++++--- 7 files changed, 53 insertions(+), 32 deletions(-) create mode 100644 features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateListener.kt create mode 100644 features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateTrigger.kt rename features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/{NotificationsUpdateTrigger.kt => DefaultNotificationsUpdateTrigger.kt} (63%) diff --git a/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateListener.kt b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateListener.kt new file mode 100644 index 0000000000..c4640cd523 --- /dev/null +++ b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateListener.kt @@ -0,0 +1,12 @@ +package com.tangem.features.send.v2.api.subcomponents.notifications + +import com.tangem.features.send.v2.api.SendNotificationsComponent.Params.NotificationData +import kotlinx.coroutines.flow.Flow + +interface SendNotificationsUpdateListener { + /** Flow triggers notifications update */ + val updateTriggerFlow: Flow + + /** Flow returns whether there is error notifications */ + val hasErrorFlow: Flow +} \ No newline at end of file diff --git a/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateTrigger.kt b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateTrigger.kt new file mode 100644 index 0000000000..54c33ec881 --- /dev/null +++ b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/subcomponents/notifications/SendNotificationsUpdateTrigger.kt @@ -0,0 +1,11 @@ +package com.tangem.features.send.v2.api.subcomponents.notifications + +import com.tangem.features.send.v2.api.SendNotificationsComponent.Params.NotificationData + +interface SendNotificationsUpdateTrigger { + /** Trigger return callback with check result */ + suspend fun callbackHasError(hasError: Boolean) + + /** Trigger fee check reload */ + suspend fun triggerUpdate(data: NotificationData) +} \ No newline at end of file diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt index 77a6703c4a..b079ab6810 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt @@ -39,6 +39,8 @@ import com.tangem.features.send.v2.api.callbacks.FeeSelectorModelCallback import com.tangem.features.send.v2.api.params.FeeSelectorParams import com.tangem.features.send.v2.api.entity.FeeSelectorUM as FeeSelectorUMRedesigned import com.tangem.features.send.v2.api.subcomponents.destination.entity.DestinationUM +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateTrigger import com.tangem.features.send.v2.common.CommonSendRoute import com.tangem.features.send.v2.common.SendBalanceUpdater import com.tangem.features.send.v2.common.SendConfirmAlertFactory @@ -58,7 +60,6 @@ import com.tangem.features.send.v2.subcomponents.fee.SendFeeCheckReloadTrigger import com.tangem.features.send.v2.subcomponents.fee.model.checkAndCalculateSubtractedAmount import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeSelectorUM import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeUM -import com.tangem.features.send.v2.subcomponents.notifications.NotificationsUpdateTrigger import com.tangem.utils.coroutines.CoroutineDispatcherProvider import com.tangem.utils.extensions.orZero import com.tangem.utils.extensions.stripZeroPlainString @@ -89,7 +90,8 @@ internal class SendConfirmModel @Inject constructor( private val isAmountSubtractAvailableUseCase: IsAmountSubtractAvailableUseCase, private val sendFeeCheckReloadTrigger: SendFeeCheckReloadTrigger, private val sendFeeCheckReloadListener: SendFeeCheckReloadListener, - private val notificationsUpdateTrigger: NotificationsUpdateTrigger, + private val notificationsUpdateTrigger: SendNotificationsUpdateTrigger, + private val notificationsUpdateListener: SendNotificationsUpdateListener, private val alertFactory: SendConfirmAlertFactory, private val sendAnalyticHelper: SendAnalyticHelper, private val urlOpener: UrlOpener, @@ -306,7 +308,7 @@ internal class SendConfirmModel @Inject constructor( } private fun subscribeOnNotificationsUpdateTrigger() { - notificationsUpdateTrigger.hasErrorFlow + notificationsUpdateListener.hasErrorFlow .onEach { hasError -> _uiState.update { if (_uiState.value.isRedesignEnabled) { diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/confirm/model/NFTSendConfirmModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/confirm/model/NFTSendConfirmModel.kt index fb152c1b84..84d7574034 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/confirm/model/NFTSendConfirmModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/confirm/model/NFTSendConfirmModel.kt @@ -30,6 +30,8 @@ import com.tangem.domain.wallets.models.requireColdWallet import com.tangem.features.nft.entity.NFTSendSuccessTrigger import com.tangem.features.send.v2.api.SendNotificationsComponent.Params.NotificationData import com.tangem.features.send.v2.api.subcomponents.destination.entity.DestinationUM +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateTrigger import com.tangem.features.send.v2.common.CommonSendRoute import com.tangem.features.send.v2.common.SendBalanceUpdater import com.tangem.features.send.v2.common.SendConfirmAlertFactory @@ -47,7 +49,6 @@ import com.tangem.features.send.v2.subcomponents.fee.SendFeeCheckReloadListener import com.tangem.features.send.v2.subcomponents.fee.SendFeeCheckReloadTrigger import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeSelectorUM import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeUM -import com.tangem.features.send.v2.subcomponents.notifications.NotificationsUpdateTrigger import com.tangem.utils.coroutines.CoroutineDispatcherProvider import com.tangem.utils.extensions.stripZeroPlainString import com.tangem.utils.transformer.update @@ -72,7 +73,8 @@ internal class NFTSendConfirmModel @Inject constructor( private val saveBlockchainErrorUseCase: SaveBlockchainErrorUseCase, private val getCardInfoUseCase: GetCardInfoUseCase, private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase, - private val notificationsUpdateTrigger: NotificationsUpdateTrigger, + private val notificationsUpdateTrigger: SendNotificationsUpdateTrigger, + private val notificationsUpdateListener: SendNotificationsUpdateListener, private val sendFeeCheckReloadTrigger: SendFeeCheckReloadTrigger, private val sendFeeCheckReloadListener: SendFeeCheckReloadListener, private val alertFactory: SendConfirmAlertFactory, @@ -242,7 +244,7 @@ internal class NFTSendConfirmModel @Inject constructor( } private fun subscribeOnNotificationsUpdateTrigger() { - notificationsUpdateTrigger.hasErrorFlow + notificationsUpdateListener.hasErrorFlow .onEach { hasError -> _uiState.update { val feeUM = it.feeUM as? FeeUM.Content diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/NotificationsUpdateTrigger.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/DefaultNotificationsUpdateTrigger.kt similarity index 63% rename from features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/NotificationsUpdateTrigger.kt rename to features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/DefaultNotificationsUpdateTrigger.kt index ed7123bbcd..8f4494843f 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/NotificationsUpdateTrigger.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/DefaultNotificationsUpdateTrigger.kt @@ -1,28 +1,17 @@ package com.tangem.features.send.v2.subcomponents.notifications import com.tangem.features.send.v2.api.SendNotificationsComponent.Params.NotificationData -import kotlinx.coroutines.flow.Flow +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateTrigger import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow import javax.inject.Inject import javax.inject.Singleton -interface NotificationsUpdateTrigger { - /** Flow triggers notifications update */ - val updateTriggerFlow: Flow - - /** Flow returns whether there is error notifications */ - val hasErrorFlow: Flow - - /** Trigger return callback with check result */ - suspend fun callbackHasError(hasError: Boolean) - - /** Trigger fee check reload */ - suspend fun triggerUpdate(data: NotificationData) -} - @Singleton -internal class DefaultNotificationsUpdateTrigger @Inject constructor() : NotificationsUpdateTrigger { +internal class DefaultNotificationsUpdateTrigger @Inject constructor() : + SendNotificationsUpdateListener, + SendNotificationsUpdateTrigger { private val _updateTriggerFlow = MutableSharedFlow() override val updateTriggerFlow = _updateTriggerFlow.asSharedFlow() diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/di/NotificationsModule.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/di/NotificationsModule.kt index 2c52cdeab5..99e88f56e9 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/di/NotificationsModule.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/di/NotificationsModule.kt @@ -1,20 +1,23 @@ package com.tangem.features.send.v2.subcomponents.notifications.di +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateTrigger import com.tangem.features.send.v2.subcomponents.notifications.DefaultNotificationsUpdateTrigger -import com.tangem.features.send.v2.subcomponents.notifications.NotificationsUpdateTrigger +import dagger.Binds import dagger.Module -import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import javax.inject.Singleton @InstallIn(SingletonComponent::class) @Module -internal object NotificationsModule { +internal interface NotificationsModule { - @Provides @Singleton - fun providesNotificationsUpdateTrigger(): NotificationsUpdateTrigger { - return DefaultNotificationsUpdateTrigger() - } + @Binds + fun bindsNotificationsUpdateTrigger(impl: DefaultNotificationsUpdateTrigger): SendNotificationsUpdateTrigger + + @Singleton + @Binds + fun bindsNotificationsUpdateListener(impl: DefaultNotificationsUpdateTrigger): SendNotificationsUpdateListener } \ No newline at end of file diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt index 726be9421e..510533e56d 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt @@ -37,12 +37,13 @@ import com.tangem.domain.transaction.usecase.ValidateTransactionUseCase import com.tangem.domain.utils.convertToSdkAmount import com.tangem.features.send.v2.api.SendNotificationsComponent import com.tangem.features.send.v2.api.SendNotificationsComponent.Params.NotificationData +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener +import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateTrigger import com.tangem.features.send.v2.subcomponents.amount.SendAmountReduceTrigger import com.tangem.features.send.v2.subcomponents.fee.SendFeeData import com.tangem.features.send.v2.subcomponents.fee.SendFeeReloadTrigger import com.tangem.features.send.v2.subcomponents.fee.model.checkAndCalculateSubtractedAmount import com.tangem.features.send.v2.subcomponents.fee.model.checkFeeCoverage -import com.tangem.features.send.v2.subcomponents.notifications.NotificationsUpdateTrigger import com.tangem.features.send.v2.subcomponents.notifications.analytics.NotificationsAnalyticEvents import com.tangem.lib.crypto.BlockchainUtils import com.tangem.lib.crypto.BlockchainUtils.isTron @@ -74,7 +75,8 @@ internal class NotificationsModel @Inject constructor( private val incrementNotificationsShowCountUseCase: IncrementNotificationsShowCountUseCase, private val sendFeeReloadTrigger: SendFeeReloadTrigger, private val sendAmountReduceTrigger: SendAmountReduceTrigger, - private val notificationsUpdateTrigger: NotificationsUpdateTrigger, + private val notificationsUpdateTrigger: SendNotificationsUpdateTrigger, + private val notificationsUpdateListener: SendNotificationsUpdateListener, private val analyticsEventHandler: AnalyticsEventHandler, ) : Model() { @@ -101,7 +103,7 @@ internal class NotificationsModel @Inject constructor( } private fun subscribeToNotificationUpdateTrigger() { - notificationsUpdateTrigger.updateTriggerFlow + notificationsUpdateListener.updateTriggerFlow .onEach { updateState(it) } .launchIn(modelScope) }