aboutsummaryrefslogtreecommitdiff
path: root/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-04-18 04:15:25 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-04-18 04:15:25 +0900
commit3301173ed41b925e0dda09c9ba19bd3d4e027962 (patch)
treecced83ecd15801a0da4bf1f06c8d40d53b3b6986 /room.cpp
parenta54109c57bdbdd7ad51c69a847c0ed3428df717b (diff)
downloadlibquotient-3301173ed41b925e0dda09c9ba19bd3d4e027962.tar.gz
libquotient-3301173ed41b925e0dda09c9ba19bd3d4e027962.zip
Added markAllMessagesAsRead()
Diffstat (limited to 'room.cpp')
-rw-r--r--room.cpp19
1 files changed, 14 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;