Skip to content

Commit 0a328ff

Browse files
committed
Merge remote-tracking branch 'remotes/origin/groovy_gluon_7.2RC' into mainnet
2 parents 4e33ab2 + 34904b4 commit 0a328ff

File tree

12 files changed

+42
-4
lines changed

12 files changed

+42
-4
lines changed

ui/model/assets_manager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,9 @@ bool AssetsManager::isVerified(beam::Asset::ID assetId) const
465465
}
466466
return false;
467467
}
468+
469+
bool AssetsManager::isKnownAsset(beam::Asset::ID assetId) const
470+
{
471+
const auto assets = _wallet->getAssetsFull();
472+
return assets.find(assetId) != assets.end();
473+
}

ui/model/assets_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class AssetsManager: public QObject
5555
[[nodiscard]] QMap<QString, QVariant> getAssetsMap(const std::set<beam::Asset::ID>& assets);
5656
[[nodiscard]] bool hasAsset(beam::Asset::ID) const;
5757
[[nodiscard]] bool isVerified(beam::Asset::ID) const;
58+
[[nodiscard]] bool isKnownAsset(beam::Asset::ID) const;
5859

5960
signals:
6061
void assetInfo(beam::Asset::ID assetId);

ui/model/wallet_model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ void WalletModel::onAssetInfo(beam::Asset::ID assetId, const beam::wallet::Walle
344344
emit assetInfoChanged(assetId, info);
345345
}
346346

347+
void WalletModel::onFullAssetsListLoaded()
348+
{
349+
emit fullAssetsListLoaded();
350+
}
351+
347352
beam::Version WalletModel::getLibVersion() const
348353
{
349354
beam::Version ver;

ui/model/wallet_model.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class WalletModel
8282
void addressChecked(const QString& addr, bool isValid);
8383
void functionPosted(const std::function<void()>&);
8484
void txHistoryExportedToCsv(const QString& data);
85+
void fullAssetsListLoaded();
8586

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

141143
#ifdef BEAM_IPFS_SUPPORT
142144
virtual void onIPFSStatus(bool running, const std::string& error, unsigned int peercnt) override;

ui/view/assets_swap.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ Item {
5656
font.pixelSize: 12
5757

5858
onClicked: {
59-
assetsSwapStackView.push(Qt.createComponent("create_asset_swap.qml"), {"onClosed": assetsSwapLayout.onClosed});
59+
assetsSwapStackView.push(Qt.createComponent("create_asset_swap.qml"), {
60+
"onClosed": function() {
61+
ordersModel.updateAssets();
62+
assetsSwapLayout.onClosed();
63+
}
64+
});
6065
}
6166
}
6267
}

ui/viewmodel/asset_swap_create_view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ AssetSwapCreateViewModel::AssetSwapCreateViewModel()
4040

4141
_myCurrenciesList = _amgr->getAssetsList();
4242
_currenciesList = _amgr->getAssetsListFull();
43-
if (_currenciesList.empty())
43+
if (_currenciesList.size() <= 1)
4444
{
4545
_currenciesList = _myCurrenciesList;
4646
}

ui/viewmodel/dex/dex_orders_list.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ DexOrdersList::DexOrdersList()
2323
: m_amgr(AppModel::getInstance().getAssets())
2424
, m_wallet(AppModel::getInstance().getWalletModel())
2525
{
26+
connect(m_wallet.get(), &WalletModel::fullAssetsListLoaded, this, &DexOrdersList::assetsListChanged);
27+
m_wallet->getAsync()->loadFullAssetsList();
2628
}
2729

2830
QHash<int, QByteArray> DexOrdersList::roleNames() const
@@ -121,6 +123,9 @@ QVariant DexOrdersList::data(const QModelIndex &index, int role) const
121123
}
122124
case Roles::RCoins:
123125
{
126+
if (!m_amgr->isKnownAsset(order.getSendAssetId()) || !m_amgr->isKnownAsset(order.getReceiveAssetId()))
127+
m_wallet->getAsync()->loadFullAssetsList();
128+
124129
QVariantMap res;
125130
res.insert("sendIcon", m_amgr->getIcon(order.getSendAssetId()));
126131
res.insert("receiveIcon", m_amgr->getIcon(order.getReceiveAssetId()));
@@ -158,3 +163,8 @@ QVariant DexOrdersList::data(const QModelIndex &index, int role) const
158163
}
159164
}
160165
}
166+
167+
void DexOrdersList::assetsListChanged()
168+
{
169+
emit layoutChanged();
170+
}

ui/viewmodel/dex/dex_orders_list.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class DexOrdersList : public ListModel<beam::wallet::DexOrder>
5353
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
5454
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
5555

56+
public slots:
57+
void assetsListChanged();
58+
5659
private:
5760
QLocale m_locale; // default
5861
AssetsManager::Ptr m_amgr;

ui/viewmodel/dex/dex_orders_model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ void DexOrdersModel::cancelOrder(QString orderId)
4343
_walletModel->getAsync()->cancelDexOrder(id);
4444
}
4545

46+
void DexOrdersModel::updateAssets()
47+
{
48+
_walletModel->getAsync()->loadFullAssetsList();
49+
}
50+
4651
void DexOrdersModel::onDexOrdersChanged(
4752
beam::wallet::ChangeAction action, const std::vector<beam::wallet::DexOrder>& orders)
4853
{

0 commit comments

Comments
 (0)