Move userConsentRequired to NeoChatConnection

This commit is contained in:
Tobias Fella
2024-01-07 19:44:37 +01:00
parent 9e2bf0da26
commit c10bcf1764
5 changed files with 11 additions and 13 deletions

View File

@@ -152,12 +152,6 @@ void Controller::addConnection(NeoChatConnection *c)
dropConnection(c);
});
connect(c, &NeoChatConnection::requestFailed, this, [this](BaseJob *job) {
if (job->error() == BaseJob::UserConsentRequired) {
Q_EMIT userConsentRequired(job->errorUrl());
}
});
c->sync();
Q_EMIT connectionAdded(c);

View File

@@ -134,6 +134,5 @@ Q_SIGNALS:
void connectionAdded(NeoChatConnection *connection);
void connectionDropped(NeoChatConnection *connection);
void activeConnectionChanged();
void userConsentRequired(QUrl url);
void accountsLoadingChanged();
};

View File

@@ -44,6 +44,11 @@ NeoChatConnection::NeoChatConnection(QObject *parent)
connect(this, &NeoChatConnection::networkError, this, [this]() {
setIsOnline(false);
});
connect(this, &NeoChatConnection::requestFailed, this, [this](BaseJob *job) {
if (job->error() == BaseJob::UserConsentRequired) {
Q_EMIT userConsentRequired(job->errorUrl());
}
});
}
NeoChatConnection::NeoChatConnection(const QUrl &server, QObject *parent)

View File

@@ -99,6 +99,7 @@ Q_SIGNALS:
void labelChanged();
void isOnlineChanged();
void passwordStatus(NeoChatConnection::PasswordStatus status);
void userConsentRequired(QUrl url);
private:
bool m_isOnline = true;

View File

@@ -300,12 +300,6 @@ Kirigami.ApplicationWindow {
function onErrorOccured(error, detail) {
showPassiveNotification(detail.length > 0 ? i18n("%1: %2", error, detail) : error);
}
function onUserConsentRequired(url) {
let consent = consentSheetComponent.createObject(QQC2.ApplicationWindow.overlay)
consent.url = url
consent.open()
}
}
Connections {
@@ -341,6 +335,11 @@ Kirigami.ApplicationWindow {
title: i18nc("@title:window", "Session Verification")
});
}
function onUserConsentRequired(url) {
let consent = consentSheetComponent.createObject(QQC2.ApplicationWindow.overlay)
consent.url = url
consent.open()
}
}
Component {