Updated on 2026-08-14

This commit is contained in:
Tangem 2025-03-31 16:35:03 +05:00
parent c5fc1a4464
commit ded9de148c
17 changed files with 183 additions and 156 deletions

View file

@ -1,5 +1,7 @@
package com.tangem.features.walletconnect.connections.model
import arrow.core.getOrElse
import com.tangem.common.routing.AppRoute
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.model.Model
import com.tangem.core.decompose.navigation.Router
@ -7,19 +9,21 @@ import com.tangem.core.decompose.ui.UiMessageSender
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.message.DialogMessage
import com.tangem.core.ui.message.EventMessageAction
import com.tangem.domain.qrscanning.models.SourceType
import com.tangem.domain.qrscanning.usecases.ListenToQrScanningUseCase
import com.tangem.features.walletconnect.connections.entity.WcConnectionsState
import com.tangem.features.walletconnect.connections.ui.preview.WcConnectionsPreviewData
import com.tangem.features.walletconnect.impl.R
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.*
import timber.log.Timber
import javax.inject.Inject
@ModelScoped
internal class WcConnectionsModel @Inject constructor(
private val router: Router,
private val uiMessageSender: UiMessageSender,
private val listenToQrScanningUseCase: ListenToQrScanningUseCase,
override val dispatchers: CoroutineDispatcherProvider,
) : Model() {
@ -31,8 +35,22 @@ internal class WcConnectionsModel @Inject constructor(
),
).asStateFlow()
init {
listenQrUpdates()
}
private fun listenQrUpdates() {
listenToQrScanningUseCase(SourceType.WALLET_CONNECT)
.getOrElse { emptyFlow() }
.onEach {
// TODO: [REDACTED_JIRA]
Timber.d(it)
}
.launchIn(modelScope)
}
private fun openQrScanScreen() {
// TODO("[REDACTED_JIRA]")
router.push(AppRoute.QrScanning(source = AppRoute.QrScanning.Source.WalletConnect))
}
private fun disconnectAll() {