From e05ab6f7ed06196377ced113e25b99e0b2d57b76 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 30 Nov 2024 09:26:31 -0500 Subject: [PATCH] fix links from offer book chart to buy/sell views --- .../offerbook/OfferBookChartViewModel.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartViewModel.java b/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartViewModel.java index 59c90088..c7d0c912 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartViewModel.java @@ -212,7 +212,10 @@ class OfferBookChartViewModel extends ActivatableViewModel { } public boolean isSellOffer(OfferDirection direction) { - return direction == OfferDirection.SELL; + // for cryptocurrency, buy direction is to buy XMR, so we need sell offers + // for traditional currency, buy direction is to sell XMR, so we need buy offers + boolean isCryptoCurrency = CurrencyUtil.isCryptoCurrency(getCurrencyCode()); + return isCryptoCurrency ? direction == OfferDirection.BUY : direction == OfferDirection.SELL; } public boolean isMyOffer(Offer offer) { @@ -423,12 +426,20 @@ class OfferBookChartViewModel extends ActivatableViewModel { private void updateScreenCurrencyInPreferences(OfferDirection direction) { if (isSellOffer(direction)) { - if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) { + if (CurrencyUtil.isFiatCurrency(getCurrencyCode())) { preferences.setBuyScreenCurrencyCode(getCurrencyCode()); + } else if (CurrencyUtil.isCryptoCurrency(getCurrencyCode())) { + preferences.setBuyScreenCryptoCurrencyCode(getCurrencyCode()); + } else if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) { + preferences.setBuyScreenOtherCurrencyCode(getCurrencyCode()); } } else { - if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) { + if (CurrencyUtil.isFiatCurrency(getCurrencyCode())) { preferences.setSellScreenCurrencyCode(getCurrencyCode()); + } else if (CurrencyUtil.isCryptoCurrency(getCurrencyCode())) { + preferences.setSellScreenCryptoCurrencyCode(getCurrencyCode()); + } else if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) { + preferences.setSellScreenOtherCurrencyCode(getCurrencyCode()); } } }