diff --git a/resources/qml/ChatPage.qml b/resources/qml/ChatPage.qml
index 082fa8d6..22a04b74 100644
--- a/resources/qml/ChatPage.qml
+++ b/resources/qml/ChatPage.qml
@@ -21,7 +21,7 @@ Rectangle {
anchors.fill: parent
singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
- pageIndex: Rooms.currentRoom ? 2 : 1
+ pageIndex: (Rooms.currentRoom || Rooms.currentRoomPreview.roomid) ? 2 : 1
AdaptiveLayoutElement {
id: communityListC
diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml
index 72ac49e1..12ecc6e8 100644
--- a/resources/qml/RoomList.qml
+++ b/resources/qml/RoomList.qml
@@ -192,6 +192,7 @@ Page {
TapHandler {
margin: -Nheko.paddingSmall
onSingleTapped: {
+ console.log("tapped "+roomId);
if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId)
Rooms.setCurrentRoom(roomId);
else
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 91bbca5b..8214d9de 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -24,7 +24,7 @@ Item {
property bool showBackButton: false
Label {
- visible: !room && !TimelineManager.isInitialSync && !roomPreview
+ visible: !room && !TimelineManager.isInitialSync && (!roomPreview || !roomPreview.roomid)
anchors.centerIn: parent
text: qsTr("No room open")
font.pointSize: 24
@@ -137,7 +137,7 @@ Item {
ColumnLayout {
id: preview
- property string roomId: room ? room.roomId : (roomPreview ? roomPreview.roomId : "")
+ property string roomId: room ? room.roomId : (roomPreview ? roomPreview.roomid : "")
property string roomName: room ? room.roomName : (roomPreview ? roomPreview.roomName : "")
property string roomTopic: room ? room.roomTopic : (roomPreview ? roomPreview.roomTopic : "")
property string avatarUrl: room ? room.roomAvatarUrl : (roomPreview ? roomPreview.roomAvatarUrl : "")
@@ -163,7 +163,7 @@ Item {
}
MatrixText {
- text: parent.roomName
+ text: parent.roomName == "" ? qsTr("No preview available") : parent.roomName
font.pixelSize: 24
Layout.alignment: Qt.AlignHCenter
}
@@ -240,7 +240,7 @@ Item {
anchors.margins: Nheko.paddingMedium
width: Nheko.avatarSize
height: Nheko.avatarSize
- visible: room != null && room.isSpace && showBackButton
+ visible: (room == null || room.isSpace) && showBackButton
enabled: visible
image: ":/icons/icons/ui/angle-pointing-to-left.png"
ToolTip.visible: hovered
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index c5bbd83c..179c63af 100644
--- a/src/timeline/RoomlistModel.cpp
+++ b/src/timeline/RoomlistModel.cpp
@@ -609,6 +609,12 @@ RoomlistModel::setCurrentRoom(QString roomid)
(currentRoomPreview_ && currentRoomPreview_->roomid() == roomid))
return;
+ if (roomid.isEmpty()) {
+ currentRoom_ = nullptr;
+ currentRoomPreview_ = {};
+ emit currentRoomChanged();
+ }
+
nhlog::ui()->debug("Trying to switch to: {}", roomid.toStdString());
if (models.contains(roomid)) {
currentRoom_ = models.value(roomid);
@@ -635,10 +641,24 @@ RoomlistModel::setCurrentRoom(QString roomid)
p.roomTopic_ = QString::fromStdString(i->topic);
p.roomAvatarUrl_ = QString::fromStdString(i->avatar_url);
currentRoomPreview_ = std::move(p);
+ nhlog::ui()->debug("Switched to (preview): {}",
+ currentRoomPreview_->roomid_.toStdString());
+ } else {
+ p.roomid_ = roomid;
+ currentRoomPreview_ = p;
+ nhlog::ui()->debug("Switched to (empty): {}",
+ currentRoomPreview_->roomid_.toStdString());
}
emit currentRoomChanged();
- nhlog::ui()->debug("Switched to: {}", roomid.toStdString());
+ } else {
+ currentRoom_ = nullptr;
+
+ RoomPreview p;
+ p.roomid_ = roomid;
+ currentRoomPreview_ = std::move(p);
+ emit currentRoomChanged();
+ nhlog::ui()->debug("Switched to (empty): {}", roomid.toStdString());
}
}
|