aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--room.cpp19
-rw-r--r--room.h4
2 files changed, 18 insertions, 5 deletions
diff --git a/room.cpp b/room.cpp
index 632e79df..47a1de04 100644
--- a/room.cpp
+++ b/room.cpp
@@ -243,11 +243,10 @@ Room::Private::promoteReadMarker(User* u, Room::rev_iter_t newMarker)
return { prevMarker, newMarker };
}
-void Room::markMessagesAsRead(QString uptoEventId)
+void Room::markMessagesAsRead(Room::rev_iter_t upToMarker)
{
User* localUser = connection()->user();
- Private::rev_iter_pair_t markers =
- d->promoteReadMarker(localUser, findInTimeline(uptoEventId));
+ Private::rev_iter_pair_t markers = d->promoteReadMarker(localUser, upToMarker);
if (markers.first != markers.second)
qDebug() << "Marked messages as read until" << *readMarker();
@@ -258,13 +257,23 @@ void Room::markMessagesAsRead(QString uptoEventId)
{
if ((*markers.second)->senderId() != localUser->id())
{
- connection()->callApi<PostReceiptJob>(this->id(),
- (*markers.second)->id());
+ connection()->callApi<PostReceiptJob>(id(), (*markers.second)->id());
break;
}
}
}
+void Room::markMessagesAsRead(QString uptoEventId)
+{
+ markMessagesAsRead(findInTimeline(uptoEventId));
+}
+
+void Room::markAllMessagesAsRead()
+{
+ if (!d->timeline.empty())
+ markMessagesAsRead(d->timeline.crbegin());
+}
+
bool Room::hasUnreadMessages()
{
return d->unreadMessages;
diff --git a/room.h b/room.h
index 704fdf00..315e4016 100644
--- a/room.h
+++ b/room.h
@@ -128,6 +128,8 @@ namespace QMatrixClient
* the nearest non-local message before. uptoEventId must be non-empty.
*/
void markMessagesAsRead(QString uptoEventId);
+ /** Mark all messages in the room as read */
+ void markAllMessagesAsRead();
Q_INVOKABLE bool hasUnreadMessages();
@@ -183,6 +185,8 @@ namespace QMatrixClient
void addNewMessageEvents(Events events);
void addHistoricalMessageEvents(Events events);
+
+ void markMessagesAsRead(rev_iter_t upToMarker);
};
class MemberSorter