Skip to content

Commit

Permalink
fix: problems showing Tx details and going to home screen afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Dec 20, 2024
1 parent 61dc67d commit dce5f3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ class TransactionResultViewModel @Inject constructor(
}
}

private suspend fun monitorTransactionMetadata(txId: Sha256Hash) {
withContext(Dispatchers.IO) {
private fun monitorTransactionMetadata(txId: Sha256Hash) {
// this might take some time, so let it run asynchronously
viewModelScope.launch(Dispatchers.IO) {
transactionMetadataProvider.importTransactionMetadata(txId)
transactionMetadataProvider.observeTransactionMetadata(txId).collect {
_transactionMetadata.value = it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ class TransactionDetailsDialogFragment : OffsetDialogFragment(R.layout.transacti
viewModel.init(txId)
viewModel.transaction.filterNotNull().observe(viewLifecycleOwner) { tx ->
// the transactionResultViewBinder.bind is called later
// if (tx == null) {
// // log.error("Transaction not found. TxId: {}", txId)
// return@observe
// }


viewModel.transactionIcon.observe(this) {
transactionResultViewBinder.setTransactionIcon(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import de.schildbach.wallet.util.WalletUtils
import de.schildbach.wallet_test.R
import de.schildbach.wallet_test.databinding.ActivitySuccessfulTransactionBinding
import de.schildbach.wallet_test.databinding.TransactionResultContentBinding
import kotlinx.coroutines.flow.filterNotNull
import org.bitcoinj.core.Sha256Hash
import org.bitcoinj.core.Transaction
import org.dash.wallet.common.services.analytics.AnalyticsConstants
Expand Down Expand Up @@ -150,27 +151,22 @@ class TransactionResultActivity : LockScreenActivity() {

viewModel.init(txId)

viewModel.transaction.observe(this) { tx ->
if (tx != null) {
transactionResultViewBinder.setTransactionIcon(R.drawable.check_animated)
contentBinding.openExplorerCard.setOnClickListener { viewOnExplorer(tx) }
contentBinding.taxCategoryLayout.setOnClickListener { viewOnTaxCategory() }
binding.transactionCloseBtn.setOnClickListener {
onTransactionDetailsDismiss()
}
contentBinding.reportIssueCard.setOnClickListener {
showReportIssue()
}

viewModel.transactionMetadata.observe(this) {
transactionResultViewBinder.setTransactionMetadata(it)
}
transactionResultViewBinder.setOnRescanTriggered { rescanBlockchain() }
} else {
log.error("Transaction not found. TxId: {}", txId)
finish()
return@observe
viewModel.transaction.filterNotNull().observe(this) { tx ->
transactionResultViewBinder.setTransactionIcon(R.drawable.check_animated)
contentBinding.openExplorerCard.setOnClickListener { viewOnExplorer(tx) }
contentBinding.taxCategoryLayout.setOnClickListener { viewOnTaxCategory() }
binding.transactionCloseBtn.setOnClickListener {
onTransactionDetailsDismiss()
}
contentBinding.reportIssueCard.setOnClickListener {
showReportIssue()
}

viewModel.transactionMetadata.observe(this) {
transactionResultViewBinder.setTransactionMetadata(it)
}
transactionResultViewBinder.setOnRescanTriggered { rescanBlockchain() }


viewModel.transactionMetadata.observe(this) {
transactionResultViewBinder.setTransactionMetadata(it)
Expand Down

0 comments on commit dce5f3d

Please sign in to comment.