Skip to content

Commit

Permalink
PWN-1052 - create a delay to show snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
gslevinkov committed Feb 21, 2024
1 parent 3db4c53 commit c47b287
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.p2p.wallet.moonpay.clientsideapi.response

import org.p2p.core.crypto.Base58String
import org.p2p.core.utils.Constants

sealed class MoonpayCurrency {
abstract val currencyId: String
abstract val amounts: MoonpayCurrencyAmounts

fun isSol() = this is CryptoToken && tokenMint == Constants.WRAPPED_SOL_MINT_B58
// it's okay to keep equals by symbol here
// because we only have non-scam wrapped SOL in/out Moonpay
fun isSol() = this is CryptoToken && tokenSymbol == Constants.SOL_SYMBOL

data class CryptoToken(
val tokenSymbol: String,
val tokenName: String,
val tokenMint: Base58String,
override val currencyId: String,
override val amounts: MoonpayCurrencyAmounts
) : MoonpayCurrency()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
package org.p2p.wallet.moonpay.ui.transaction

import android.content.res.Resources
import org.threeten.bp.ZonedDateTime
import org.threeten.bp.format.DateTimeFormatter
import timber.log.Timber
import java.util.Locale
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.p2p.core.utils.Constants
import org.p2p.core.utils.getHtmlString
import org.p2p.core.utils.removeLinksUnderline
import org.p2p.wallet.R
import org.p2p.wallet.common.date.isSameDayAs
import org.p2p.wallet.common.date.toZonedDateTime
import org.p2p.wallet.common.mvp.BasePresenter
import org.p2p.wallet.history.analytics.HistoryAnalytics
import org.p2p.wallet.history.interactor.HistoryInteractor
import org.p2p.wallet.moonpay.model.SellTransaction
import org.p2p.wallet.moonpay.repository.sell.MoonpaySellCancelResult
import org.p2p.wallet.moonpay.serversideapi.response.SellTransactionStatus
import org.p2p.wallet.sell.interactor.HistoryItemMapper
import org.p2p.wallet.sell.interactor.SellInteractor
import org.p2p.wallet.sell.ui.lock.SellTransactionViewDetails
import org.p2p.wallet.user.interactor.UserTokensInteractor
import org.p2p.wallet.utils.CUT_ADDRESS_SYMBOLS_COUNT
import org.p2p.wallet.utils.cutMiddle
import org.p2p.wallet.utils.emptyString
import org.p2p.wallet.utils.unsafeLazy
import org.threeten.bp.ZonedDateTime
import org.threeten.bp.format.DateTimeFormatter
import timber.log.Timber
import java.util.Locale
import kotlinx.coroutines.launch
import org.p2p.wallet.history.analytics.HistoryAnalytics
import org.p2p.wallet.history.interactor.HistoryInteractor
import org.p2p.wallet.moonpay.model.SellTransaction
import org.p2p.wallet.sell.interactor.HistoryItemMapper
import org.p2p.wallet.user.interactor.UserTokensInteractor
import org.p2p.wallet.utils.CUT_ADDRESS_SYMBOLS_COUNT

private const val DATE_FORMAT = "MMMM dd, yyyy"
private const val TIME_FORMAT = "HH:mm"
Expand Down Expand Up @@ -213,6 +214,9 @@ class SellTransactionDetailsPresenter(
when (val result = sellInteractor.cancelTransaction(transaction.transactionId)) {
is MoonpaySellCancelResult.CancelSuccess -> {
view?.showUiKitSnackBar(messageResId = R.string.sell_details_cancel_success)
// I put a 1 second delay here because Snackbar doesn't have any change to appear
// the view closes too fast
delay(1000)
view?.close()
}
is MoonpaySellCancelResult.CancelFailed -> {
Expand Down

0 comments on commit c47b287

Please sign in to comment.