From c10bcf17649ad603cd02e4c0535cd537c85c92f1 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sun, 7 Jan 2024 19:44:37 +0100 Subject: [PATCH] Move userConsentRequired to NeoChatConnection --- src/controller.cpp | 6 ------ src/controller.h | 1 - src/neochatconnection.cpp | 5 +++++ src/neochatconnection.h | 1 + src/qml/main.qml | 11 +++++------ 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index b6f78708c..6fbf77edb 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -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); diff --git a/src/controller.h b/src/controller.h index dc3500fa8..80c8cc8e7 100644 --- a/src/controller.h +++ b/src/controller.h @@ -134,6 +134,5 @@ Q_SIGNALS: void connectionAdded(NeoChatConnection *connection); void connectionDropped(NeoChatConnection *connection); void activeConnectionChanged(); - void userConsentRequired(QUrl url); void accountsLoadingChanged(); }; diff --git a/src/neochatconnection.cpp b/src/neochatconnection.cpp index 0665c2b2e..133997aca 100644 --- a/src/neochatconnection.cpp +++ b/src/neochatconnection.cpp @@ -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) diff --git a/src/neochatconnection.h b/src/neochatconnection.h index 20c714f1f..863eb54ca 100644 --- a/src/neochatconnection.h +++ b/src/neochatconnection.h @@ -99,6 +99,7 @@ Q_SIGNALS: void labelChanged(); void isOnlineChanged(); void passwordStatus(NeoChatConnection::PasswordStatus status); + void userConsentRequired(QUrl url); private: bool m_isOnline = true; diff --git a/src/qml/main.qml b/src/qml/main.qml index 577e69089..402023006 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -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 {