aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-01-08 14:09:17 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-01-08 14:09:17 +0900
commitfb4127da9db32e5e18b14beaaabbee7adf9cc334 (patch)
treec14ba3abd15c380dd6430240dba46c615fc5eee8
parent0e9c56561888cbd786d099bc7d004223e7406e6a (diff)
downloadlibquotient-fb4127da9db32e5e18b14beaaabbee7adf9cc334.tar.gz
libquotient-fb4127da9db32e5e18b14beaaabbee7adf9cc334.zip
Simplified Room::Private::readMarker() code
-rw-r--r--room.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/room.cpp b/room.cpp
index 3b74607a..650b2ff0 100644
--- a/room.cpp
+++ b/room.cpp
@@ -252,9 +252,10 @@ bool Room::hasUnreadMessages()
Room::Timeline::const_iterator Room::Private::readMarker(const User* user) const
{
- return lastReadEventIds.contains(user) ?
- std::next(eventsIndex.value(lastReadEventIds.value(user))) :
- timeline.begin();
+ auto lastReadId = lastReadEventIds.value(user);
+ return lastReadId.isEmpty() ?
+ eventsIndex.value(lastReadId) + 1 :
+ timeline.begin();
}
QString Room::readMarkerEventId() const