aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--room.cpp18
-rw-r--r--room.h5
2 files changed, 11 insertions, 12 deletions
diff --git a/room.cpp b/room.cpp
index 674f0343..df230e38 100644
--- a/room.cpp
+++ b/room.cpp
@@ -169,32 +169,30 @@ void Room::setLastReadEvent(User* user, QString eventId)
emit lastReadEventChanged(user);
}
-void Room::markMessagesAsRead(Timeline::const_iterator end)
+void Room::markMessagesAsRead(Timeline::const_iterator last)
{
- if (messageEvents().empty())
- return;
-
QString prevLastReadId = lastReadEvent(connection()->user());
- setLastReadEvent(connection()->user(), (*--end)->id());
+ setLastReadEvent(connection()->user(), (*last)->id());
// We shouldn't send read receipts for messages from the local user - so
// shift back (if necessary) to the nearest message not from the local user
// or the so far last read message, whichever comes first.
- for (; (*end)->id() != prevLastReadId; --end)
+ for (; (*last)->id() != prevLastReadId; --last)
{
- if ((*end)->senderId() != connection()->userId())
+ if ((*last)->senderId() != connection()->userId())
{
- d->connection->postReceipt(this, (*end));
+ d->connection->postReceipt(this, (*last));
break;
}
- if (end == messageEvents().begin())
+ if (last == messageEvents().begin())
break;
}
}
void Room::markMessagesAsRead()
{
- markMessagesAsRead(messageEvents().end());
+ if (!messageEvents().empty())
+ markMessagesAsRead(messageEvents().end() - 1);
}
QString Room::lastReadEvent(User* user)
diff --git a/room.h b/room.h
index 049efeb6..9c745199 100644
--- a/room.h
+++ b/room.h
@@ -70,7 +70,6 @@ namespace QMatrixClient
Q_INVOKABLE void setJoinState( JoinState state );
Q_INVOKABLE QString lastReadEvent(User* user);
- Q_INVOKABLE void setLastReadEvent(User* user, QString eventId);
/**
* @brief Mark the message at the iterator as read
*
@@ -78,7 +77,7 @@ namespace QMatrixClient
* receipt to the server either for this message or, if it's from
* the local user, for the nearest non-local message before.
*/
- Q_INVOKABLE void markMessagesAsRead(Timeline::const_iterator iter);
+ Q_INVOKABLE void markMessagesAsRead(Timeline::const_iterator last);
/**
* @brief Mark the most recent message in the timeline as read
*
@@ -125,6 +124,8 @@ namespace QMatrixClient
virtual void processStateEvents(const Events& events);
virtual void processEphemeralEvent(Event* event);
+ void setLastReadEvent(User* user, QString eventId);
+
private:
class Private;
Private* d;