From de5642011eade2afdab473fc9655a112a4055ed8 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Tue, 12 Dec 2023 17:18:13 +0100 Subject: [PATCH] plugins: localmonero: fix ws notifier --- src/plugins/localmonero/LocalMoneroWidget.cpp | 14 +++++++++++--- src/utils/WebsocketNotifier.cpp | 4 ---- src/utils/WebsocketNotifier.h | 5 ----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/plugins/localmonero/LocalMoneroWidget.cpp b/src/plugins/localmonero/LocalMoneroWidget.cpp index cc97404..2b5dad3 100644 --- a/src/plugins/localmonero/LocalMoneroWidget.cpp +++ b/src/plugins/localmonero/LocalMoneroWidget.cpp @@ -42,9 +42,17 @@ LocalMoneroWidget::LocalMoneroWidget(QWidget *parent, Wallet *wallet) connect(m_api, &LocalMoneroApi::ApiResponse, this, &LocalMoneroWidget::onApiResponse); connect(ui->btn_loadMore, &QPushButton::clicked, this, &LocalMoneroWidget::onLoadMore); - connect(websocketNotifier(), &WebsocketNotifier::LocalMoneroCountriesReceived, this, &LocalMoneroWidget::onWsCountriesReceived); - connect(websocketNotifier(), &WebsocketNotifier::LocalMoneroCurrenciesReceived, this, &LocalMoneroWidget::onWsCurrenciesReceived); - connect(websocketNotifier(), &WebsocketNotifier::LocalMoneroPaymentMethodsReceived, this, &LocalMoneroWidget::onWsPaymentMethodsReceived); + connect(websocketNotifier(), &WebsocketNotifier::dataReceived, this, [this](const QString& type, const QJsonValue& json) { + if (type == "localmonero_countries") { + this->onWsCountriesReceived(json.toArray()); + } + else if (type == "localmonero_currencies") { + this->onWsCurrenciesReceived(json.toArray()); + } + else if (type == "localmonero_payment_methods") { + this->onWsPaymentMethodsReceived(json.toObject()); + } + }); connect(ui->combo_currency, QOverload::of(&QComboBox::currentIndexChanged), this, &LocalMoneroWidget::updatePaymentMethods); diff --git a/src/utils/WebsocketNotifier.cpp b/src/utils/WebsocketNotifier.cpp index 8f18d70..c58e26b 100644 --- a/src/utils/WebsocketNotifier.cpp +++ b/src/utils/WebsocketNotifier.cpp @@ -109,10 +109,6 @@ void WebsocketNotifier::onWSUpdates(const QJsonObject &updates) { emit UpdatesReceived(updates); } -void WebsocketNotifier::onWSXMRigDownloads(const QJsonObject &downloads) { - emit XMRigDownloadsReceived(downloads); -} - WebsocketNotifier* WebsocketNotifier::instance() { if (!m_instance) { diff --git a/src/utils/WebsocketNotifier.h b/src/utils/WebsocketNotifier.h index 34c9fd9..5795299 100644 --- a/src/utils/WebsocketNotifier.h +++ b/src/utils/WebsocketNotifier.h @@ -34,10 +34,6 @@ signals: void FiatRatesReceived(const QJsonObject &fiat_rates); void TxFiatHistoryReceived(const QJsonObject &data); void UpdatesReceived(const QJsonObject &updates); - void XMRigDownloadsReceived(const QJsonObject &downloads); - void LocalMoneroCountriesReceived(const QJsonArray &countries); - void LocalMoneroCurrenciesReceived(const QJsonArray ¤cies); - void LocalMoneroPaymentMethodsReceived(const QJsonObject &payment_methods); void dataReceived(const QString &type, const QJsonValue &json); private slots: @@ -45,7 +41,6 @@ private slots: void onWSNodes(const QJsonArray &nodes); void onWSUpdates(const QJsonObject &updates); - void onWSXMRigDownloads(const QJsonObject &downloads); private: static QPointer m_instance;