Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/groovy_gluon_7.2RC' into…
Browse files Browse the repository at this point in the history
… mainnet
  • Loading branch information
anatolse committed Oct 19, 2022
2 parents 4e33ab2 + 34904b4 commit 0a328ff
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ui/model/assets_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,9 @@ bool AssetsManager::isVerified(beam::Asset::ID assetId) const
}
return false;
}

bool AssetsManager::isKnownAsset(beam::Asset::ID assetId) const
{
const auto assets = _wallet->getAssetsFull();
return assets.find(assetId) != assets.end();
}
1 change: 1 addition & 0 deletions ui/model/assets_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AssetsManager: public QObject
[[nodiscard]] QMap<QString, QVariant> getAssetsMap(const std::set<beam::Asset::ID>& assets);
[[nodiscard]] bool hasAsset(beam::Asset::ID) const;
[[nodiscard]] bool isVerified(beam::Asset::ID) const;
[[nodiscard]] bool isKnownAsset(beam::Asset::ID) const;

signals:
void assetInfo(beam::Asset::ID assetId);
Expand Down
5 changes: 5 additions & 0 deletions ui/model/wallet_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ void WalletModel::onAssetInfo(beam::Asset::ID assetId, const beam::wallet::Walle
emit assetInfoChanged(assetId, info);
}

void WalletModel::onFullAssetsListLoaded()
{
emit fullAssetsListLoaded();
}

beam::Version WalletModel::getLibVersion() const
{
beam::Version ver;
Expand Down
2 changes: 2 additions & 0 deletions ui/model/wallet_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class WalletModel
void addressChecked(const QString& addr, bool isValid);
void functionPosted(const std::function<void()>&);
void txHistoryExportedToCsv(const QString& data);
void fullAssetsListLoaded();

#if defined(BEAM_HW_WALLET)
void showTrezorMessage();
Expand Down Expand Up @@ -137,6 +138,7 @@ class WalletModel
void onNotificationsChanged(beam::wallet::ChangeAction, const std::vector<beam::wallet::Notification>&) override;
void onPublicAddress(const std::string& publicAddr) override;
void onAssetInfo(beam::Asset::ID, const beam::wallet::WalletAsset&) override;
void onFullAssetsListLoaded() override;

#ifdef BEAM_IPFS_SUPPORT
virtual void onIPFSStatus(bool running, const std::string& error, unsigned int peercnt) override;
Expand Down
7 changes: 6 additions & 1 deletion ui/view/assets_swap.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ Item {
font.pixelSize: 12

onClicked: {
assetsSwapStackView.push(Qt.createComponent("create_asset_swap.qml"), {"onClosed": assetsSwapLayout.onClosed});
assetsSwapStackView.push(Qt.createComponent("create_asset_swap.qml"), {
"onClosed": function() {
ordersModel.updateAssets();
assetsSwapLayout.onClosed();
}
});
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/viewmodel/asset_swap_create_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ AssetSwapCreateViewModel::AssetSwapCreateViewModel()

_myCurrenciesList = _amgr->getAssetsList();
_currenciesList = _amgr->getAssetsListFull();
if (_currenciesList.empty())
if (_currenciesList.size() <= 1)
{
_currenciesList = _myCurrenciesList;
}
Expand Down
10 changes: 10 additions & 0 deletions ui/viewmodel/dex/dex_orders_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ DexOrdersList::DexOrdersList()
: m_amgr(AppModel::getInstance().getAssets())
, m_wallet(AppModel::getInstance().getWalletModel())
{
connect(m_wallet.get(), &WalletModel::fullAssetsListLoaded, this, &DexOrdersList::assetsListChanged);
m_wallet->getAsync()->loadFullAssetsList();
}

QHash<int, QByteArray> DexOrdersList::roleNames() const
Expand Down Expand Up @@ -121,6 +123,9 @@ QVariant DexOrdersList::data(const QModelIndex &index, int role) const
}
case Roles::RCoins:
{
if (!m_amgr->isKnownAsset(order.getSendAssetId()) || !m_amgr->isKnownAsset(order.getReceiveAssetId()))
m_wallet->getAsync()->loadFullAssetsList();

QVariantMap res;
res.insert("sendIcon", m_amgr->getIcon(order.getSendAssetId()));
res.insert("receiveIcon", m_amgr->getIcon(order.getReceiveAssetId()));
Expand Down Expand Up @@ -158,3 +163,8 @@ QVariant DexOrdersList::data(const QModelIndex &index, int role) const
}
}
}

void DexOrdersList::assetsListChanged()
{
emit layoutChanged();
}
3 changes: 3 additions & 0 deletions ui/viewmodel/dex/dex_orders_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class DexOrdersList : public ListModel<beam::wallet::DexOrder>
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;

public slots:
void assetsListChanged();

private:
QLocale m_locale; // default
AssetsManager::Ptr m_amgr;
Expand Down
5 changes: 5 additions & 0 deletions ui/viewmodel/dex/dex_orders_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ void DexOrdersModel::cancelOrder(QString orderId)
_walletModel->getAsync()->cancelDexOrder(id);
}

void DexOrdersModel::updateAssets()
{
_walletModel->getAsync()->loadFullAssetsList();
}

void DexOrdersModel::onDexOrdersChanged(
beam::wallet::ChangeAction action, const std::vector<beam::wallet::DexOrder>& orders)
{
Expand Down
1 change: 1 addition & 0 deletions ui/viewmodel/dex/dex_orders_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class DexOrdersModel : public QObject

QAbstractItemModel* getOrders();
Q_INVOKABLE void cancelOrder(QString orderId);
Q_INVOKABLE void updateAssets();

signals:
void ordersChanged();
Expand Down
2 changes: 1 addition & 1 deletion ui/viewmodel/main_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ QString MainViewModel::getFaucetAppID() const

QString MainViewModel::getEthBridgeAppID() const
{
const std::string appName = "Bridges app";
std::string appName = "Bridges app";
std::string appURL = "";

#if defined(BEAM_TESTNET)
Expand Down

0 comments on commit 0a328ff

Please sign in to comment.