From 388e0c28bd7e9f14884150069be1a967c2aa3168 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 7 Jan 2023 01:39:08 +0100 Subject: [PATCH] Navigate to space when room is selected fixes #1260 --- resources/qml/RoomList.qml | 3 --- src/timeline/CommunitiesModel.cpp | 3 +++ src/timeline/RoomlistModel.cpp | 4 ++++ src/timeline/RoomlistModel.h | 1 + src/timeline/TimelineViewManager.cpp | 3 +++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml index 2cfd71f9..24b62fd2 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml @@ -257,9 +257,6 @@ Page { onClicked: { console.log("tapped " + roomId); - if (isSpace && Communities.currentTagId != "space:"+roomId) - Communities.currentTagId = "space:"+roomId; - if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId) Rooms.setCurrentRoom(roomId); else diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp index 9f34c3ff..92b6017d 100644 --- a/src/timeline/CommunitiesModel.cpp +++ b/src/timeline/CommunitiesModel.cpp @@ -579,6 +579,9 @@ CommunitiesModel::sync(const mtx::responses::Sync &sync_) void CommunitiesModel::setCurrentTagId(const QString &tagId) { + if (currentTagId_ == tagId) + return; + if (tagId.startsWith(QLatin1String("tag:"))) { auto tag = tagId.mid(4); for (const auto &t : qAsConst(tags_)) { diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index 64eca182..5bd12a36 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -768,6 +768,10 @@ RoomlistModel::setCurrentRoom(const QString &roomid) currentRoomPreview_.reset(); emit currentRoomChanged(currentRoom_->roomId()); nhlog::ui()->debug("Switched to: {}", roomid.toStdString()); + + if (currentRoom_->isSpace()) { + emit spaceSelected(roomid); + } } else if (invites.contains(roomid) || previewedRooms.contains(roomid)) { currentRoom_ = nullptr; std::optional i; diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h index 81907dff..4b312ddc 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -129,6 +129,7 @@ signals: void totalUnreadMessageCountUpdated(int unreadMessages); void currentRoomChanged(QString currentRoomId); void fetchedPreview(QString roomid, RoomInfo info); + void spaceSelected(QString roomId); private: void addRoom(const QString &room_id, bool suppressInsertNotification = false); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index ba586ef9..5d08e05e 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -152,6 +152,9 @@ TimelineViewManager::TimelineViewManager(CallManager *, ChatPage *parent) isConnected_ = true; emit isConnectedChanged(true); }); + connect(rooms_, &RoomlistModel::spaceSelected, communities_, [this](QString roomId) { + communities_->setCurrentTagId("space:" + roomId); + }); } void