[#1456] runCreateTransactions on lifecycleScope
- Closes #1456 - Also, these changes leverage updated snapshot Zcash SDK version 2.1.2 - Changelog update
This commit is contained in:
parent
030d2e20b0
commit
75e90607d1
|
@ -15,6 +15,10 @@ directly impact users rather than highlighting other key architectural updates.*
|
|||
### Changed
|
||||
- The color palette used across the app has been reworked to align with the updated design document
|
||||
|
||||
### Fixed
|
||||
- An updated snapshot Zcash SDK version has been adopted to improve unstable lightwalletd communication
|
||||
- Transaction submission has been slightly refactored to improve its stability
|
||||
|
||||
## [1.1 (655)] - 2024-05-24
|
||||
|
||||
### Added
|
||||
|
|
|
@ -201,7 +201,11 @@ class WalletViewModel(application: Application) : AndroidViewModel(application)
|
|||
synchronizer
|
||||
.filterNotNull()
|
||||
.map {
|
||||
WalletAddresses.new(it)
|
||||
runCatching {
|
||||
WalletAddresses.new(it)
|
||||
}.onFailure {
|
||||
Twig.warn { "Wait until the SDK starts providing the addresses" }
|
||||
}.getOrNull()
|
||||
}.stateIn(
|
||||
viewModelScope,
|
||||
SharingStarted.WhileSubscribed(ANDROID_STATE_FLOW_TIMEOUT),
|
||||
|
|
|
@ -4,7 +4,6 @@ package co.electriccoin.zcash.ui.screen.balances
|
|||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -14,11 +13,13 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import cash.z.ecc.android.sdk.SdkSynchronizer
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.model.UnifiedSpendingKey
|
||||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import co.electriccoin.zcash.spackle.Twig
|
||||
import co.electriccoin.zcash.ui.MainActivity
|
||||
import co.electriccoin.zcash.ui.R
|
||||
import co.electriccoin.zcash.ui.common.compose.BalanceState
|
||||
import co.electriccoin.zcash.ui.common.model.WalletRestoringState
|
||||
|
@ -43,7 +44,7 @@ import org.jetbrains.annotations.VisibleForTesting
|
|||
|
||||
@Composable
|
||||
internal fun WrapBalances(
|
||||
activity: ComponentActivity,
|
||||
activity: MainActivity,
|
||||
goSettings: () -> Unit,
|
||||
goMultiTrxSubmissionFailure: () -> Unit,
|
||||
) {
|
||||
|
@ -74,6 +75,7 @@ internal fun WrapBalances(
|
|||
checkUpdateViewModel = checkUpdateViewModel,
|
||||
goSettings = goSettings,
|
||||
goMultiTrxSubmissionFailure = goMultiTrxSubmissionFailure,
|
||||
lifecycleScope = activity.lifecycleScope,
|
||||
spendingKey = spendingKey,
|
||||
synchronizer = synchronizer,
|
||||
walletSnapshot = walletSnapshot,
|
||||
|
@ -93,6 +95,7 @@ internal fun WrapBalances(
|
|||
createTransactionsViewModel: CreateTransactionsViewModel,
|
||||
goSettings: () -> Unit,
|
||||
goMultiTrxSubmissionFailure: () -> Unit,
|
||||
lifecycleScope: CoroutineScope,
|
||||
spendingKey: UnifiedSpendingKey?,
|
||||
synchronizer: Synchronizer?,
|
||||
walletSnapshot: WalletSnapshot?,
|
||||
|
@ -157,7 +160,7 @@ internal fun WrapBalances(
|
|||
hideStatusDialog = { showStatusDialog.value = null },
|
||||
snackbarHostState = snackbarHostState,
|
||||
onShielding = {
|
||||
scope.launch {
|
||||
lifecycleScope.launch {
|
||||
setShieldState(ShieldState.Running)
|
||||
|
||||
Twig.debug { "Shielding transparent funds" }
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package co.electriccoin.zcash.ui.screen.home
|
||||
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -104,7 +103,7 @@ internal fun MainActivity.WrapHome(
|
|||
@Suppress("LongParameterList", "LongMethod")
|
||||
@Composable
|
||||
internal fun WrapHome(
|
||||
activity: ComponentActivity,
|
||||
activity: MainActivity,
|
||||
goBack: () -> Unit,
|
||||
goSettings: () -> Unit,
|
||||
goMultiTrxSubmissionFailure: () -> Unit,
|
||||
|
|
|
@ -16,6 +16,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import cash.z.ecc.android.sdk.SdkSynchronizer
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.model.Proposal
|
||||
|
@ -44,6 +45,7 @@ import co.electriccoin.zcash.ui.screen.support.viewmodel.SupportViewModel
|
|||
import co.electriccoin.zcash.ui.util.EmailUtil
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
@ -76,10 +78,11 @@ internal fun MainActivity.WrapSendConfirmation(
|
|||
activity = this,
|
||||
arguments = arguments,
|
||||
authenticationViewModel = authenticationViewModel,
|
||||
createTransactionsViewModel = createTransactionsViewModel,
|
||||
goBack = goBack,
|
||||
goHome = goHome,
|
||||
goSupport = goSupport,
|
||||
createTransactionsViewModel = createTransactionsViewModel,
|
||||
lifecycleScope = this.lifecycleScope,
|
||||
spendingKey = spendingKey,
|
||||
supportMessage = supportMessage,
|
||||
synchronizer = synchronizer,
|
||||
|
@ -94,10 +97,11 @@ internal fun WrapSendConfirmation(
|
|||
activity: MainActivity,
|
||||
arguments: SendConfirmationArguments,
|
||||
authenticationViewModel: AuthenticationViewModel,
|
||||
createTransactionsViewModel: CreateTransactionsViewModel,
|
||||
goBack: (clearForm: Boolean) -> Unit,
|
||||
goHome: () -> Unit,
|
||||
goSupport: () -> Unit,
|
||||
createTransactionsViewModel: CreateTransactionsViewModel,
|
||||
lifecycleScope: CoroutineScope,
|
||||
spendingKey: UnifiedSpendingKey?,
|
||||
supportMessage: SupportInfo?,
|
||||
synchronizer: Synchronizer?,
|
||||
|
@ -179,7 +183,7 @@ internal fun WrapSendConfirmation(
|
|||
},
|
||||
onConfirmation = {
|
||||
// Check and trigger authentication if required, or just submit transactions otherwise
|
||||
scope.launch {
|
||||
lifecycleScope.launch {
|
||||
authenticationViewModel.isSendFundsAuthenticationRequired
|
||||
.filterNotNull()
|
||||
.collect { isProtected ->
|
||||
|
@ -211,7 +215,7 @@ internal fun WrapSendConfirmation(
|
|||
goSupport()
|
||||
},
|
||||
onSuccess = {
|
||||
scope.launch {
|
||||
lifecycleScope.launch {
|
||||
runSendFundsAction(
|
||||
createTransactionsViewModel = createTransactionsViewModel,
|
||||
goHome = goHome,
|
||||
|
|
Loading…
Reference in New Issue