diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-10-20 09:38:16 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-10-20 09:40:51 +0900 |
commit | 372ed74c04f2c542451771aa792242a4e2afb351 (patch) | |
tree | f47f5ade12fc60ad1eca6ecfe0354a8fd212dde9 | |
parent | b44ad3573d21c456014d7983669acc31dd6eebdf (diff) | |
download | libquotient-372ed74c04f2c542451771aa792242a4e2afb351.tar.gz libquotient-372ed74c04f2c542451771aa792242a4e2afb351.zip |
Room: added setLastReadEvent accessor and a signal for it; don't post receipts for own messages to the server
As discussed with Matthew in #quaternion: https://matrix.to/#/!PCzUtxtOjUySxSelof:matrix.org/$14768896199130qcJqe:matrix.org
-rw-r--r-- | room.cpp | 12 | ||||
-rw-r--r-- | room.h | 2 |
2 files changed, 12 insertions, 2 deletions
@@ -163,9 +163,17 @@ void Room::setJoinState(JoinState state) emit joinStateChanged(oldState, state); } +void Room::setLastReadEvent(User* user, QString eventId) +{ + d->lastReadEvent.insert(user, eventId); + emit lastReadEventChanged(user); +} + void Room::markMessageAsRead(Event* event) { - d->connection->postReceipt(this, event); + setLastReadEvent(connection()->user(), event->id()); + if (event->senderId() != connection()->userId()) + d->connection->postReceipt(this, event); } QString Room::lastReadEvent(User* user) @@ -489,7 +497,7 @@ void Room::processEphemeralEvent(Event* event) for( const Receipt& r: receipts ) { if (auto m = d->member(r.userId)) - d->lastReadEvent.insert(m, eventId); + setLastReadEvent(m, eventId); } } } @@ -69,6 +69,7 @@ namespace QMatrixClient Q_INVOKABLE void updateData(SyncRoomData& data ); Q_INVOKABLE void setJoinState( JoinState state ); + Q_INVOKABLE void setLastReadEvent(User* user, QString eventId); Q_INVOKABLE void markMessageAsRead( Event* event ); Q_INVOKABLE QString lastReadEvent(User* user); @@ -102,6 +103,7 @@ namespace QMatrixClient void typingChanged(); void highlightCountChanged(Room* room); void notificationCountChanged(Room* room); + void lastReadEventChanged(User* user); protected: Connection* connection() const; |