From d0c41d522474120be388a597a3eab9b6dba8d89d Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Thu, 1 Aug 2024 21:03:18 +0200 Subject: [PATCH] Ensure that room list does not show rooms without title during startup There's a brief moment during startup where the model knows about the rooms, but their state is not loaded, which makes them show up in the room list with ugly fallback titles. To prevent this, we delay closing the welcome page until the basestate is loaded. (cherry picked from commit bd1d4289c0e94f5d34f52e2befcb91fd3a53635a) --- src/controller.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 66d73ad6e..9dc71eb42 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -202,10 +202,24 @@ void Controller::invokeLogin() m_connectionsLoading[accountId] = connection; connect(connection, &NeoChatConnection::connected, this, [this, connection, accountId] { connection->loadState(); - addConnection(connection); - m_accountsLoading.removeAll(connection->userId()); - m_connectionsLoading.remove(accountId); - Q_EMIT accountsLoadingChanged(); + if (connection->allRooms().size() == 0 || connection->allRooms()[0]->currentState().get()) { + addConnection(connection); + m_accountsLoading.removeAll(connection->userId()); + m_connectionsLoading.remove(accountId); + Q_EMIT accountsLoadingChanged(); + } else { + connect( + connection->allRooms()[0], + &Room::baseStateLoaded, + this, + [this, connection, accountId]() { + addConnection(connection); + m_accountsLoading.removeAll(connection->userId()); + m_connectionsLoading.remove(accountId); + Q_EMIT accountsLoadingChanged(); + }, + Qt::SingleShotConnection); + } }); connect(connection, &NeoChatConnection::networkError, this, [this](const QString &error, const QString &, int, int) { Q_EMIT errorOccured(i18n("Network Error: %1", error), {});