Updated on 2026-08-14

This commit is contained in:
Tangem 2025-03-31 13:14:48 +03:00
parent d452b4ca23
commit ce92d75db4
6 changed files with 4 additions and 16 deletions

View file

@ -108,11 +108,11 @@ internal var lockUserWalletsTimer: LockUserWalletsTimer? = null
var notificationsHandler: NotificationsHandler? = null
private val coroutineContext: CoroutineContext
get() = Job() + Dispatchers.IO + FeatureCoroutineExceptionHandler.create("scope")
get() = SupervisorJob() + Dispatchers.IO + FeatureCoroutineExceptionHandler.create("scope")
val scope = CoroutineScope(coroutineContext)
private val mainCoroutineContext: CoroutineContext
get() = Job() + Dispatchers.Main + FeatureCoroutineExceptionHandler.create("mainScope")
get() = SupervisorJob() + Dispatchers.Main + FeatureCoroutineExceptionHandler.create("mainScope")
val mainScope = CoroutineScope(mainCoroutineContext)
@Suppress("LargeClass")

View file

@ -15,7 +15,6 @@ import com.tangem.tap.features.welcome.redux.WelcomeAction
import com.tangem.tap.features.welcome.redux.WelcomeState
import com.tangem.tap.features.welcome.ui.WelcomeScreenState
import com.tangem.tap.features.welcome.ui.model.WarningModel
import com.tangem.tap.mainScope
import com.tangem.tap.store
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.flow.MutableStateFlow
@ -42,8 +41,6 @@ internal class WelcomeModel @Inject constructor(
val state: MutableStateFlow<WelcomeScreenState> = MutableStateFlow(initialState)
init {
store.dispatch(WelcomeAction.SetCoroutineScope(mainScope))
subscribeToStoreChanges()
initGlobalState()
@ -89,7 +86,6 @@ internal class WelcomeModel @Inject constructor(
}
override fun onDestroy() {
store.dispatch(WelcomeAction.ClearCoroutineScope)
store.unsubscribe(subscriber = this)
super.onDestroy()

View file

@ -2,15 +2,10 @@ package com.tangem.tap.features.welcome.redux
import android.content.Intent
import com.tangem.common.core.TangemError
import kotlinx.coroutines.CoroutineScope
import org.rekotlin.Action
internal sealed interface WelcomeAction : Action {
data class SetCoroutineScope(val scope: CoroutineScope) : WelcomeAction
object ClearCoroutineScope : WelcomeAction
data class ProceedWithBiometrics(val afterUnlockIntent: Intent? = null) : WelcomeAction {
object Success : WelcomeAction
data class Error(val error: TangemError) : WelcomeAction

View file

@ -23,6 +23,7 @@ import com.tangem.tap.common.extensions.*
import com.tangem.tap.common.redux.AppState
import com.tangem.tap.features.intentHandler.handlers.BackgroundScanIntentHandler
import com.tangem.tap.features.intentHandler.handlers.WalletConnectLinkIntentHandler
import com.tangem.tap.mainScope
import com.tangem.tap.proxy.redux.DaggerGraphState
import com.tangem.tap.scope
import com.tangem.tap.store
@ -46,7 +47,7 @@ internal class WelcomeMiddleware {
}
private fun handleAction(action: WelcomeAction, state: WelcomeState) {
state.scope?.launch {
mainScope.launch {
when (action) {
is WelcomeAction.ProceedWithIntent -> proceedWithIntent(action.intent, scope = this)
is WelcomeAction.ProceedWithBiometrics -> proceedWithBiometrics(

View file

@ -14,8 +14,6 @@ internal object WelcomeReducer {
private fun internalReduce(action: WelcomeAction, state: WelcomeState): WelcomeState {
return when (action) {
is WelcomeAction.SetCoroutineScope -> state.copy(scope = action.scope)
is WelcomeAction.ClearCoroutineScope -> state.copy(scope = null)
is WelcomeAction.ProceedWithIntent -> state.copy(intent = action.intent)
is WelcomeAction.ProceedWithBiometrics -> state.copy(isUnlockWithBiometricsInProgress = true)
is WelcomeAction.ProceedWithCard -> state.copy(isUnlockWithCardInProgress = true)

View file

@ -2,11 +2,9 @@ package com.tangem.tap.features.welcome.redux
import android.content.Intent
import com.tangem.common.core.TangemError
import kotlinx.coroutines.CoroutineScope
import org.rekotlin.StateType
data class WelcomeState(
val scope: CoroutineScope? = null,
val isUnlockWithBiometricsInProgress: Boolean = false,
val isUnlockWithCardInProgress: Boolean = false,
val intent: Intent? = null,