summary refs log tree commit diff
path: root/src/timeline/RoomlistModel.cpp
diff options
context:
space:
mode:
authorHiers <47784553+Hiers@users.noreply.github.com>2022-09-11 23:05:20 +0000
committerGitHub <noreply@github.com>2022-09-11 23:05:20 +0000
commit8071b192b8cecf0b0f422d74678038dd3afbe3bc (patch)
treee5340dccf4ad742a86199e82758a9de5eff038fb /src/timeline/RoomlistModel.cpp
parentMerge pull request #1163 from foresto/log-options (diff)
downloadnheko-8071b192b8cecf0b0f422d74678038dd3afbe3bc.tar.xz
Line to indicate first unread message (#1147)
* First draft of unread line feature.

* Minor visual fix.

* Removed unnecessary ternary operator.

* Extended unread line functionality to work on minimised window or focusing another window.

* Fix for unread line not showing when last read message is hidden.

* Minor performance improvement. Fix for misbehaving event2order DB at application start.

* Fix for possible performance issues when user has joined a large number of rooms.

* Fix for breaking macos and clazy builds.

* Changed on windows focus function to refresh unread line if room is unread.

* Unread line is removed when user sends a message.

* Linting.

* Fixed unread line to work in standalone room windows.

* Switch isRoomUnread for index 0.

* Merged try/catch blocks.

* Fix for crash on opening a room invite.

* Call fullyReadEventId function when used instead of storing it and passing it through.

* Function that was meant to sync the unread line was relying on an async function, oops.

* Linting again.

* More linting...

* Minor changes.
Diffstat (limited to 'src/timeline/RoomlistModel.cpp')
-rw-r--r--src/timeline/RoomlistModel.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index 03abd3d5..6e95ef8e 100644
--- a/src/timeline/RoomlistModel.cpp
+++ b/src/timeline/RoomlistModel.cpp
@@ -283,6 +283,14 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
         QSharedPointer<TimelineModel> newRoom(new TimelineModel(manager, room_id));
         newRoom->setDecryptDescription(ChatPage::instance()->userSettings()->decryptSidebar());
 
+        connect(this,
+                &RoomlistModel::currentRoomChanged,
+                newRoom.data(),
+                &TimelineModel::updateLastReadId);
+        connect(MainWindow::instance(),
+                &MainWindow::activeChanged,
+                newRoom.data(),
+                &TimelineModel::lastReadIdOnWindowFocus);
         connect(newRoom.data(),
                 &TimelineModel::newEncryptedImage,
                 MainWindow::instance()->imageProvider(),
@@ -383,7 +391,7 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
             currentRoomPreview_->roomid() == room_id) {
             currentRoom_ = models.value(room_id);
             currentRoomPreview_.reset();
-            emit currentRoomChanged();
+            emit currentRoomChanged(room_id);
         }
 
         for (auto p : previewsToAdd) {
@@ -644,7 +652,7 @@ RoomlistModel::clear()
     invites.clear();
     roomids.clear();
     currentRoom_ = nullptr;
-    emit currentRoomChanged();
+    emit currentRoomChanged("");
     endResetModel();
 }
 
@@ -743,14 +751,14 @@ RoomlistModel::setCurrentRoom(QString roomid)
     if (roomid.isEmpty()) {
         currentRoom_        = nullptr;
         currentRoomPreview_ = {};
-        emit currentRoomChanged();
+        emit currentRoomChanged("");
     }
 
     nhlog::ui()->debug("Trying to switch to: {}", roomid.toStdString());
     if (models.contains(roomid)) {
         currentRoom_ = models.value(roomid);
         currentRoomPreview_.reset();
-        emit currentRoomChanged();
+        emit currentRoomChanged(currentRoom_->roomId());
         nhlog::ui()->debug("Switched to: {}", roomid.toStdString());
     } else if (invites.contains(roomid) || previewedRooms.contains(roomid)) {
         currentRoom_ = nullptr;
@@ -781,7 +789,7 @@ RoomlistModel::setCurrentRoom(QString roomid)
                                currentRoomPreview_->roomid_.toStdString());
         }
 
-        emit currentRoomChanged();
+        emit currentRoomChanged("");
     }
 }