Updated on 2026-08-14
This commit is contained in:
commit
4de7d3ba74
7 changed files with 86 additions and 9 deletions
|
|
@ -0,0 +1,8 @@
|
|||
package com.tangem.features.nft.entity
|
||||
|
||||
/**
|
||||
* Trigger on success nft send
|
||||
*/
|
||||
interface NFTSendSuccessTrigger {
|
||||
suspend fun triggerSuccessNFTSend()
|
||||
}
|
||||
|
|
@ -19,18 +19,22 @@ import com.tangem.features.nft.common.ui.NFTContent
|
|||
import com.tangem.features.nft.component.NFTComponent
|
||||
import com.tangem.features.nft.details.NFTDetailsComponent
|
||||
import com.tangem.features.nft.details.info.NFTDetailsInfoComponent
|
||||
import com.tangem.features.nft.entity.NFTSendSuccessListener
|
||||
import com.tangem.features.nft.receive.NFTReceiveComponent
|
||||
import com.tangem.features.nft.traits.NFTAssetTraitsComponent
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
internal class DefaultNFTComponent @AssistedInject constructor(
|
||||
@Assisted appComponentContext: AppComponentContext,
|
||||
@Assisted private val params: NFTComponent.Params,
|
||||
private val nftDetailsInfoComponentFactory: NFTDetailsInfoComponent.Factory,
|
||||
nftSendSuccessListener: NFTSendSuccessListener,
|
||||
) : NFTComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val stackNavigation = StackNavigation<NFTRoute>()
|
||||
|
|
@ -69,6 +73,11 @@ internal class DefaultNFTComponent @AssistedInject constructor(
|
|||
currentRoute.emit(stack.active.configuration)
|
||||
}
|
||||
}
|
||||
nftSendSuccessListener.nftSendSuccessFlow
|
||||
.onEach {
|
||||
innerRouter.popTo(NFTRoute.Collections(userWalletId = params.userWalletId))
|
||||
}
|
||||
.launchIn(componentScope)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ import com.tangem.features.nft.details.block.DefaultNFTDetailsBlockComponent
|
|||
import com.tangem.features.nft.details.info.DefaultNFTDetailsInfoComponent
|
||||
import com.tangem.features.nft.details.info.NFTDetailsInfoComponent
|
||||
import com.tangem.features.nft.details.model.NFTDetailsModel
|
||||
import com.tangem.features.nft.entity.DefaultNFTSendSuccessTrigger
|
||||
import com.tangem.features.nft.entity.NFTSendSuccessListener
|
||||
import com.tangem.features.nft.entity.NFTSendSuccessTrigger
|
||||
import com.tangem.features.nft.receive.model.NFTReceiveModel
|
||||
import com.tangem.features.nft.traits.model.NFTAssetTraitsModel
|
||||
import dagger.Binds
|
||||
|
|
@ -71,4 +74,12 @@ internal interface NFTFeatureModuleBinds {
|
|||
@IntoMap
|
||||
@ClassKey(NFTAssetTraitsModel::class)
|
||||
fun bindNFTTraitsModel(model: NFTAssetTraitsModel): Model
|
||||
|
||||
@Binds
|
||||
@Singleton
|
||||
fun bindNFTSendSuccessTrigger(impl: DefaultNFTSendSuccessTrigger): NFTSendSuccessTrigger
|
||||
|
||||
@Binds
|
||||
@Singleton
|
||||
fun bindNFTSendSuccessListener(impl: DefaultNFTSendSuccessTrigger): NFTSendSuccessListener
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.tangem.features.nft.entity
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Listens to success nft send trigger
|
||||
*/
|
||||
interface NFTSendSuccessListener {
|
||||
val nftSendSuccessFlow: Flow<Unit>
|
||||
}
|
||||
|
||||
@Singleton
|
||||
internal class DefaultNFTSendSuccessTrigger @Inject constructor() : NFTSendSuccessTrigger, NFTSendSuccessListener {
|
||||
|
||||
override val nftSendSuccessFlow: SharedFlow<Unit>
|
||||
field = MutableSharedFlow<Unit>()
|
||||
|
||||
override suspend fun triggerSuccessNFTSend() {
|
||||
nftSendSuccessFlow.emit(Unit)
|
||||
}
|
||||
}
|
||||
|
|
@ -57,6 +57,7 @@ dependencies {
|
|||
implementation(projects.domain.balanceHiding.models)
|
||||
implementation(projects.domain.balanceHiding)
|
||||
implementation(projects.domain.nft.models)
|
||||
implementation(projects.domain.nft)
|
||||
implementation(projects.domain.notifications)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.features.send.v2.common
|
||||
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.nft.RefreshAllNFTUseCase
|
||||
import com.tangem.domain.tokens.FetchPendingTransactionsUseCase
|
||||
import com.tangem.domain.tokens.UpdateDelayedNetworkStatusUseCase
|
||||
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase
|
||||
|
|
@ -22,6 +23,7 @@ internal class SendBalanceUpdater @AssistedInject constructor(
|
|||
private val getTxHistoryItemsUseCase: GetTxHistoryItemsUseCase,
|
||||
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
||||
private val txHistoryContentUpdateEmitter: TxHistoryContentUpdateEmitter,
|
||||
private val refreshAllNFTUseCase: RefreshAllNFTUseCase,
|
||||
@DelayedWork private val coroutineScope: CoroutineScope,
|
||||
@Assisted private val userWallet: UserWallet,
|
||||
@Assisted private val cryptoCurrency: CryptoCurrency,
|
||||
|
|
@ -43,10 +45,20 @@ internal class SendBalanceUpdater @AssistedInject constructor(
|
|||
async {
|
||||
updateNetworkStatuses()
|
||||
},
|
||||
async {
|
||||
updateNFT()
|
||||
},
|
||||
).awaitAll()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateNFT() {
|
||||
delay(BALANCE_UPDATE_DELAY)
|
||||
refreshAllNFTUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun updateNetworkStatuses(delay: Long = BALANCE_UPDATE_DELAY) {
|
||||
updateDelayedNetworkStatusUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.tangem.domain.settings.NeverShowTapHelpUseCase
|
|||
import com.tangem.domain.transaction.usecase.CreateNFTTransferTransactionUseCase
|
||||
import com.tangem.domain.transaction.usecase.SendTransactionUseCase
|
||||
import com.tangem.domain.txhistory.usecase.GetExplorerTransactionUrlUseCase
|
||||
import com.tangem.features.nft.entity.NFTSendSuccessTrigger
|
||||
import com.tangem.features.send.v2.common.CommonSendRoute
|
||||
import com.tangem.features.send.v2.common.SendBalanceUpdater
|
||||
import com.tangem.features.send.v2.common.SendConfirmAlertFactory
|
||||
|
|
@ -78,6 +79,7 @@ internal class NFTSendConfirmModel @Inject constructor(
|
|||
private val shareManager: ShareManager,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
private val nftSendAnalyticHelper: NFTSendAnalyticHelper,
|
||||
private val nftSendSuccessTrigger: NFTSendSuccessTrigger,
|
||||
sendBalanceUpdaterFactory: SendBalanceUpdater.Factory,
|
||||
) : Model(), NFTSendConfirmClickIntents {
|
||||
|
||||
|
|
@ -404,15 +406,7 @@ internal class NFTSendConfirmModel @Inject constructor(
|
|||
isEnabled = confirmUM.isPrimaryButtonEnabled,
|
||||
isHapticClick = isReadyToSend,
|
||||
onClick = {
|
||||
when (confirmUM) {
|
||||
is ConfirmUM.Success -> appRouter.pop()
|
||||
is ConfirmUM.Content -> if (confirmUM.isSending) {
|
||||
return@PrimaryButtonUM
|
||||
} else {
|
||||
onSendClick()
|
||||
}
|
||||
else -> return@PrimaryButtonUM
|
||||
}
|
||||
onNextClick(confirmUM)
|
||||
},
|
||||
),
|
||||
prevButton = null,
|
||||
|
|
@ -430,6 +424,23 @@ internal class NFTSendConfirmModel @Inject constructor(
|
|||
}.launchIn(modelScope)
|
||||
}
|
||||
|
||||
private fun onNextClick(confirmUM: ConfirmUM) {
|
||||
when (confirmUM) {
|
||||
is ConfirmUM.Success -> {
|
||||
modelScope.launch {
|
||||
nftSendSuccessTrigger.triggerSuccessNFTSend()
|
||||
}
|
||||
appRouter.pop()
|
||||
}
|
||||
is ConfirmUM.Content -> if (confirmUM.isSending) {
|
||||
return
|
||||
} else {
|
||||
onSendClick()
|
||||
}
|
||||
else -> return
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val CHECK_FEE_UPDATE_DELAY = 10_000L
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue