Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trade confirm modal ticker icons wrong #2134

Merged
4 commits merged into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion atomic_defi_design/Dex/Components/PairItemBadge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import QtQuick.Layouts 1.15

import bignumberjs 1.0

import "../Constants"

DefaultRectangle
{
id: root
property alias source: icon.source
property alias ticker: ticker.text
property alias fullname: fullname.text
property string amount
Expand All @@ -31,6 +32,7 @@ DefaultRectangle
Layout.preferredWidth: 35
Layout.preferredHeight: 35
Layout.alignment: Qt.AlignVCenter
source: General.coinIcon(root.ticker)
}

Item { Layout.fillWidth: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ MultipageModal

PairItemBadge
{
source: General.coinIcon(!details ? atomic_app_primary_coin : details.base_coin)
ticker: details ? details.base_coin : ""
fullname: details ? General.coinName(details.base_coin) : ""
amount: details ? details.base_amount : ""
Expand All @@ -78,7 +77,6 @@ MultipageModal

PairItemBadge
{
source: General.coinIcon(!details ? atomic_app_primary_coin : details.rel_coin)
ticker: details ? details.rel_coin : ""
fullname: details ? General.coinName(details.rel_coin) : ""
amount: details ? details.rel_amount : ""
Expand Down
2 changes: 0 additions & 2 deletions atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ MultipageModal

PairItemBadge
{
source: General.coinIcon(!base_ticker ? atomic_app_primary_coin : base_ticker)
ticker: base_ticker
fullname: General.coinName(base_ticker)
amount: base_amount
Expand All @@ -54,7 +53,6 @@ MultipageModal

PairItemBadge
{
source: General.coinIcon(!rel_ticker ? atomic_app_primary_coin : rel_ticker)
ticker: rel_ticker
fullname: General.coinName(rel_ticker)
amount: rel_amount
Expand Down
6 changes: 5 additions & 1 deletion atomic_defi_design/Dex/Exchange/Trade/ProView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ RowLayout
property alias bestOrders: bestOrders
property alias placeOrderForm: placeOrderForm

function selectOrder(is_asks, coin, price, price_denom, price_numer, min_volume, base_min_volume, base_max_volume, rel_min_volume, rel_max_volume, base_max_volume_denom, base_max_volume_numer, uuid)
function selectOrder(
is_asks, coin, price, price_denom,
price_numer, min_volume, base_min_volume, base_max_volume,
rel_min_volume, rel_max_volume, base_max_volume_denom,
base_max_volume_numer, uuid)
{
setMarketMode(!is_asks ? MarketMode.Sell : MarketMode.Buy)

Expand Down
33 changes: 25 additions & 8 deletions src/core/atomicdex/pages/qt.trading.page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,16 +1040,25 @@ namespace atomic_dex
return {};
}

void
trading_page::set_preferred_order(const QVariantMap& price_object)
void trading_page::set_preferred_order(const QVariantMap& price_object)
{
if (auto preferred_order = nlohmann::json::parse(QString(QJsonDocument(QJsonObject::fromVariantMap(price_object)).toJson()).toStdString());
preferred_order != m_preferred_order)
auto preferred_order = nlohmann::json::parse(QString(QJsonDocument(QJsonObject::fromVariantMap(price_object)).toJson()).toStdString());
if (preferred_order == m_preferred_order)
{
return;
}
SPDLOG_DEBUG("preferred_order: {}", preferred_order.dump(-1));
m_preferred_order = std::move(preferred_order);
emit prefferedOrderChanged();
if (!m_preferred_order->empty() && m_preferred_order->contains("price"))
{
SPDLOG_DEBUG("preferred_order: {}", preferred_order.dump(-1));
m_preferred_order = std::move(preferred_order);
emit prefferedOrderChanged();
if (!m_preferred_order->empty() && m_preferred_order->contains("price"))
m_preferred_order->operator[]("capped") = false;
this->set_price(QString::fromStdString(utils::format_float(safe_float(m_preferred_order->at("price").get<std::string>()))));
this->determine_max_volume();
QString min_vol = QString::fromStdString(utils::format_float(safe_float(m_preferred_order->at("base_min_volume").get<std::string>())));
this->set_min_trade_vol(min_vol);
auto available_quantity = m_preferred_order->at("base_max_volume").get<std::string>();
if (this->m_current_trading_mode == TradingModeGadget::Pro)
{
m_preferred_order->operator[]("capped") = false;
this->set_price(QString::fromStdString(utils::format_float(safe_float(m_preferred_order->at("price").get<std::string>()))));
Expand All @@ -1064,6 +1073,14 @@ namespace atomic_dex
this->get_orderbook_wrapper()->refresh_best_orders();
emit preferredOrderChangeFinished();
}
else if (this->m_current_trading_mode == TradingModeGadget::Simple && m_preferred_order->contains("initial_input_volume"))
{
SPDLOG_DEBUG("From simple view, using initial_input_volume from selection to use.");
this->set_volume(QString::fromStdString(m_preferred_order->at("initial_input_volume").get<std::string>()));
}
this->get_orderbook_wrapper()->refresh_best_orders();
this->determine_fees();
emit preferredOrderChangeFinished();
}
}

Expand Down