summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-11-03 22:35:54 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-11-03 22:35:54 +0100
commit1a163f49e21ca64704460d292f1bf665be7e6c76 (patch)
tree2a0186e09b12a599ba46feb70fba59c7490875d0
parentFix copyright order (diff)
downloadnheko-1a163f49e21ca64704460d292f1bf665be7e6c76.tar.xz
Fix unjoinable invites on mobile as well as unclickable previews
-rw-r--r--resources/qml/ChatPage.qml2
-rw-r--r--resources/qml/RoomList.qml1
-rw-r--r--resources/qml/TimelineView.qml8
-rw-r--r--src/timeline/RoomlistModel.cpp22
4 files changed, 27 insertions, 6 deletions
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());
     }
 }