Updated on 2026-08-14
This commit is contained in:
parent
b469ed7a13
commit
27f3c6afda
4 changed files with 37 additions and 4 deletions
|
|
@ -1,8 +1,10 @@
|
|||
@file:Suppress("Filename")
|
||||
|
||||
package com.tangem.tap.di
|
||||
|
||||
import javax.inject.Qualifier
|
||||
|
||||
@Deprecated("Use one in Core Utils")
|
||||
@Qualifier
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class DelayedWork
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.tangem.utils.coroutines
|
||||
|
||||
import javax.inject.Qualifier
|
||||
|
||||
@Qualifier
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class DelayedWork
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.utils.di
|
||||
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.DelayedWork
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object DelayedWorkCoroutineModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@DelayedWork
|
||||
fun provideDelayedWorkCoroutineScope(coroutineDispatcherProvider: CoroutineDispatcherProvider): CoroutineScope {
|
||||
return CoroutineScope(SupervisorJob() + coroutineDispatcherProvider.io)
|
||||
}
|
||||
}
|
||||
|
|
@ -56,9 +56,11 @@ import com.tangem.features.send.impl.presentation.state.fee.*
|
|||
import com.tangem.lib.crypto.BlockchainUtils
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.DelayedWork
|
||||
import com.tangem.utils.coroutines.JobHolder
|
||||
import com.tangem.utils.coroutines.saveIn
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
|
@ -97,6 +99,7 @@ internal class SendViewModel @Inject constructor(
|
|||
private val addCryptoCurrenciesUseCase: AddCryptoCurrenciesUseCase,
|
||||
private val updateDelayedCurrencyStatusUseCase: UpdateDelayedNetworkStatusUseCase,
|
||||
private val fetchPendingTransactionsUseCase: FetchPendingTransactionsUseCase,
|
||||
@DelayedWork private val coroutineScope: CoroutineScope,
|
||||
currencyChecksRepository: CurrencyChecksRepository,
|
||||
isFeeApproximateUseCase: IsFeeApproximateUseCase,
|
||||
validateWalletMemoUseCase: ValidateWalletMemoUseCase,
|
||||
|
|
@ -890,11 +893,9 @@ internal class SendViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun scheduleUpdates() {
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
coroutineScope.launch {
|
||||
// we should update network to find pending tx after 1 sec
|
||||
fetchPendingTransactionsUseCase(userWallet.walletId, setOf(cryptoCurrency.network))
|
||||
}
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
// we should update network for new balance
|
||||
updateDelayedCurrencyStatusUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
|
|
@ -954,7 +955,7 @@ internal class SendViewModel @Inject constructor(
|
|||
|
||||
private companion object {
|
||||
const val CHECK_FEE_UPDATE_DELAY = 60_000L
|
||||
const val BALANCE_UPDATE_DELAY = 10_000L
|
||||
const val BALANCE_UPDATE_DELAY = 11_000L
|
||||
|
||||
const val RU_LOCALE = "ru"
|
||||
const val EN_LOCALE = "en"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue