From 6dcfad1f8d5f08b857f146fe9f598c2b08d9df9b Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 5 Feb 2021 23:49:02 +0100 Subject: [PATCH] Don't show login page when starting NeoChat This was caused by us calling initiated to early. Only do it when no accounts exists or that at least one account fails to login. Fix #248 --- qml/main.qml | 3 +++ src/controller.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qml/main.qml b/qml/main.qml index 66f3d4df9..dbdfdcdd1 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -251,6 +251,9 @@ Kirigami.ApplicationWindow { target: Controller function onInitiated() { + if (roomManager.hasOpenRoom) { + return; + } if (Controller.accountCount === 0) { pageStack.replace("qrc:/imports/NeoChat/Page/LoginPage.qml", {}); } else { diff --git a/src/controller.cpp b/src/controller.cpp index 57e922126..c15b0b1fc 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -282,6 +282,7 @@ void Controller::invokeLogin() Q_EMIT errorOccured(i18n("Login Failed"), error); logout(connection, true); } + Q_EMIT initiated(); }); connect(connection, &Connection::networkError, this, [=](const QString &error, const QString &, int, int) { Q_EMIT errorOccured("Network Error", error); @@ -289,7 +290,7 @@ void Controller::invokeLogin() connection->connectWithToken(account.userId(), accessToken, account.deviceId()); } } - if (m_connections.isEmpty()) { + if (accounts.isEmpty()) { Q_EMIT initiated(); } }