Fix unjoinable invites on mobile as well as unclickable previews

This commit is contained in:
Nicolas Werner 2021-11-03 22:35:54 +01:00
parent 912a8c43b2
commit 1a163f49e2
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
4 changed files with 27 additions and 6 deletions

View file

@ -21,7 +21,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
pageIndex: Rooms.currentRoom ? 2 : 1 pageIndex: (Rooms.currentRoom || Rooms.currentRoomPreview.roomid) ? 2 : 1
AdaptiveLayoutElement { AdaptiveLayoutElement {
id: communityListC id: communityListC

View file

@ -192,6 +192,7 @@ Page {
TapHandler { TapHandler {
margin: -Nheko.paddingSmall margin: -Nheko.paddingSmall
onSingleTapped: { onSingleTapped: {
console.log("tapped "+roomId);
if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId) if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId)
Rooms.setCurrentRoom(roomId); Rooms.setCurrentRoom(roomId);
else else

View file

@ -24,7 +24,7 @@ Item {
property bool showBackButton: false property bool showBackButton: false
Label { Label {
visible: !room && !TimelineManager.isInitialSync && !roomPreview visible: !room && !TimelineManager.isInitialSync && (!roomPreview || !roomPreview.roomid)
anchors.centerIn: parent anchors.centerIn: parent
text: qsTr("No room open") text: qsTr("No room open")
font.pointSize: 24 font.pointSize: 24
@ -137,7 +137,7 @@ Item {
ColumnLayout { ColumnLayout {
id: preview 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 roomName: room ? room.roomName : (roomPreview ? roomPreview.roomName : "")
property string roomTopic: room ? room.roomTopic : (roomPreview ? roomPreview.roomTopic : "") property string roomTopic: room ? room.roomTopic : (roomPreview ? roomPreview.roomTopic : "")
property string avatarUrl: room ? room.roomAvatarUrl : (roomPreview ? roomPreview.roomAvatarUrl : "") property string avatarUrl: room ? room.roomAvatarUrl : (roomPreview ? roomPreview.roomAvatarUrl : "")
@ -163,7 +163,7 @@ Item {
} }
MatrixText { MatrixText {
text: parent.roomName text: parent.roomName == "" ? qsTr("No preview available") : parent.roomName
font.pixelSize: 24 font.pixelSize: 24
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
@ -240,7 +240,7 @@ Item {
anchors.margins: Nheko.paddingMedium anchors.margins: Nheko.paddingMedium
width: Nheko.avatarSize width: Nheko.avatarSize
height: Nheko.avatarSize height: Nheko.avatarSize
visible: room != null && room.isSpace && showBackButton visible: (room == null || room.isSpace) && showBackButton
enabled: visible enabled: visible
image: ":/icons/icons/ui/angle-pointing-to-left.png" image: ":/icons/icons/ui/angle-pointing-to-left.png"
ToolTip.visible: hovered ToolTip.visible: hovered

View file

@ -609,6 +609,12 @@ RoomlistModel::setCurrentRoom(QString roomid)
(currentRoomPreview_ && currentRoomPreview_->roomid() == roomid)) (currentRoomPreview_ && currentRoomPreview_->roomid() == roomid))
return; return;
if (roomid.isEmpty()) {
currentRoom_ = nullptr;
currentRoomPreview_ = {};
emit currentRoomChanged();
}
nhlog::ui()->debug("Trying to switch to: {}", roomid.toStdString()); nhlog::ui()->debug("Trying to switch to: {}", roomid.toStdString());
if (models.contains(roomid)) { if (models.contains(roomid)) {
currentRoom_ = models.value(roomid); currentRoom_ = models.value(roomid);
@ -635,10 +641,24 @@ RoomlistModel::setCurrentRoom(QString roomid)
p.roomTopic_ = QString::fromStdString(i->topic); p.roomTopic_ = QString::fromStdString(i->topic);
p.roomAvatarUrl_ = QString::fromStdString(i->avatar_url); p.roomAvatarUrl_ = QString::fromStdString(i->avatar_url);
currentRoomPreview_ = std::move(p); 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(); 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());
} }
} }