diff --git a/src/dialogs/ReCaptcha.cpp b/src/dialogs/ReCaptcha.cpp
index ba487cea..6b1143b5 100644
--- a/src/dialogs/ReCaptcha.cpp
+++ b/src/dialogs/ReCaptcha.cpp
@@ -6,6 +6,7 @@
#include "Config.h"
#include "FlatButton.h"
+#include "MatrixClient.h"
#include "RaisedButton.h"
#include "Theme.h"
@@ -13,7 +14,7 @@
using namespace dialogs;
-ReCaptcha::ReCaptcha(const QString &server, const QString &session, QWidget *parent)
+ReCaptcha::ReCaptcha(const QString &session, QWidget *parent)
: QWidget(parent)
{
setAutoFillBackground(true);
@@ -51,12 +52,12 @@ ReCaptcha::ReCaptcha(const QString &server, const QString &session, QWidget *par
layout->addWidget(label);
layout->addLayout(buttonLayout);
- connect(openCaptchaBtn_, &QPushButton::clicked, [server, session]() {
- const auto url =
- QString(
- "https://%1/_matrix/client/r0/auth/m.login.recaptcha/fallback/web?session=%2")
- .arg(server)
- .arg(session);
+ connect(openCaptchaBtn_, &QPushButton::clicked, [session]() {
+ const auto url = QString("https://%1:%2/_matrix/client/r0/auth/m.login.recaptcha/"
+ "fallback/web?session=%3")
+ .arg(QString::fromStdString(http::v2::client()->server()))
+ .arg(http::v2::client()->port())
+ .arg(session);
QDesktopServices::openUrl(url);
});
diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp
index 4d2f304b..2396fc19 100644
--- a/src/dialogs/RoomSettings.cpp
+++ b/src/dialogs/RoomSettings.cpp
@@ -67,6 +67,20 @@ EditModal::EditModal(const QString &roomId, QWidget *parent)
labelLayout->addWidget(errorField_);
layout->addLayout(labelLayout);
+ connect(this, &EditModal::stateEventErrorCb, this, [this](const QString &msg) {
+ errorField_->setText(msg);
+ errorField_->show();
+ });
+ connect(this, &EditModal::nameEventSentCb, this, [this](const QString &newName) {
+ errorField_->hide();
+ emit nameChanged(newName);
+ close();
+ });
+ connect(this, &EditModal::topicEventSentCb, this, [this]() {
+ errorField_->hide();
+ close();
+ });
+
connect(applyBtn_, &QPushButton::clicked, [this]() {
// Check if the values are changed from the originals.
auto newName = nameInput_->text().trimmed();
@@ -85,53 +99,37 @@ EditModal::EditModal(const QString &roomId, QWidget *parent)
state::Name body;
body.name = newName.toStdString();
- auto proxy =
- http::client()->sendStateEvent<state::Name, EventType::RoomName>(body,
- roomId_);
- connect(proxy.get(),
- &StateEventProxy::stateEventSent,
- this,
- [this, proxy, newName]() {
- Q_UNUSED(proxy);
- errorField_->hide();
- emit nameChanged(newName);
- close();
- });
-
- connect(proxy.get(),
- &StateEventProxy::stateEventError,
- this,
- [this, proxy, newName](const QString &msg) {
- Q_UNUSED(proxy);
- errorField_->setText(msg);
- errorField_->show();
- });
+ http::v2::client()->send_state_event<state::Name, EventType::RoomName>(
+ roomId_.toStdString(),
+ body,
+ [this, newName](const mtx::responses::EventId &,
+ mtx::http::RequestErr err) {
+ if (err) {
+ emit stateEventErrorCb(
+ QString::fromStdString(err->matrix_error.error));
+ return;
+ }
+
+ emit nameEventSentCb(newName);
+ });
}
if (newTopic != initialTopic_ && !newTopic.isEmpty()) {
state::Topic body;
body.topic = newTopic.toStdString();
- auto proxy =
- http::client()->sendStateEvent<state::Topic, EventType::RoomTopic>(
- body, roomId_);
- connect(proxy.get(),
- &StateEventProxy::stateEventSent,
- this,
- [this, proxy, newTopic]() {
- Q_UNUSED(proxy);
- errorField_->hide();
- close();
- });
-
- connect(proxy.get(),
- &StateEventProxy::stateEventError,
- this,
- [this, proxy, newTopic](const QString &msg) {
- Q_UNUSED(proxy);
- errorField_->setText(msg);
- errorField_->show();
- });
+ http::v2::client()->send_state_event<state::Topic, EventType::RoomTopic>(
+ roomId_.toStdString(),
+ body,
+ [this](const mtx::responses::EventId &, mtx::http::RequestErr err) {
+ if (err) {
+ emit stateEventErrorCb(
+ QString::fromStdString(err->matrix_error.error));
+ return;
+ }
+
+ emit topicEventSentCb();
+ });
}
});
connect(cancelBtn_, &QPushButton::clicked, this, &EditModal::close);
|