Merge pull request #1532 from Nheko-Reborn/issue1512

Add mark room as read option
pull/1535/head
DeepBlueV7.X 1 year ago committed by GitHub
commit b2b8945f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      resources/qml/RoomList.qml
  2. 17
      src/timeline/TimelineModel.cpp
  3. 2
      src/timeline/TimelineModel.h

@ -726,6 +726,11 @@ Page {
destroyOnClose(roomWindow);
}
}
Platform.MenuItem {
text: qsTr("Mark as read")
onTriggered: Rooms.getRoomById(roomContextMenu.roomid).markRoomAsRead()
}
Platform.MenuItem {
text: qsTr("Room settings")

@ -1283,14 +1283,21 @@ TimelineModel::updateLastMessage()
void
TimelineModel::setCurrentIndex(int index)
{
setCurrentIndex(index, false);
}
void
TimelineModel::setCurrentIndex(int index, bool ignoreInactiveState)
{
auto oldIndex = idToIndex(currentId);
currentId = indexToId(index);
if (index != oldIndex)
emit currentIndexChanged(index);
if (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() ||
MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow())
if (!ignoreInactiveState &&
(!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() ||
MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow()))
return;
if (!currentId.startsWith('m')) {
@ -1561,6 +1568,12 @@ TimelineModel::markEventsAsRead(const std::vector<QString> &event_ids)
}
}
void
TimelineModel::markRoomAsRead()
{
setCurrentIndex(0, true);
}
void
TimelineModel::updateLastReadId(const QString &currentRoomId)
{

@ -386,9 +386,11 @@ public:
public slots:
void setCurrentIndex(int index);
void setCurrentIndex(int index, bool ignoreInactiveState);
int currentIndex() const { return idToIndex(currentId); }
void eventShown();
void markEventsAsRead(const std::vector<QString> &event_ids);
void markRoomAsRead();
void updateLastReadId(const QString &currentRoomId);
void lastReadIdOnWindowFocus();
void checkAfterFetch();

Loading…
Cancel
Save