Age | Commit message (Collapse) | Author |
|
timeline + no more discarding read markers to events that haven't arrived yet
When using deque::const_reverse_iterator for read markers and eventsIndex, I didn't realise that insertions into std::deque invalidate iterators (though preserve references and pointers). Therefore, a small TimelineItem class has been introduced that stores an event together with a persistent index that is generated upon insertion into the timeline (timeline.back()+1 for newer events, timeline.front()-1 for older events). Using such indices, we can still reach an event by it's index in constant time, while avoiding a problem with invalidating iterators.
While rewriting the code, another problem has been detected with read markers to events that haven't yet arrived to the timeline (in particular, older events). The old code simply discarded such read markers. The new code stores such read markers anyway, so that when that event arrives, it could be matched against the stored last-read-event id.
|
|
|
|
|
|
Connection::callApi + Room::getPreviousMessages(limit)
|
|
Also, Room now uses callApi<PostReceiptJob>() instead of postReceipt()
(to allow further removal of postReceipt() from Connection)
|
|
This call (intended to only be used within the lib) creates a job object of the passed type and passes a ConnectionData pointer to its constructor. This allows to avoid making a switchboard of methods on Connection for the whole API, leaving only those that naturally belong there - e.g. joinRoom() or sync() - and moving, e.g., postMessage() to where it belongs - Room. PostMessageJob and RoomMessagesJob were updated along the way, to unbind from the Room class (which they really don't and won't need).
|
|
Fix adding events to the timeline
|
|
|
|
forbid empty event id's
Added assertions and enhanced debug messages along the way
|
|
there
Because these fall outside of SyncJob and Event context, respectively. In addition, Owning<> has gained a move assignment operator (because we have a move constructor) and assign() convenience method to take ownership over an existing container; also, Owning<>::release() is done the right way now (the previous version was copying the return value to a new container instead of releasing the old container).
|
|
This is not quite correct because only room events are guaranteed by the spec to have an id and a timestamp. But we don't parse all room events as of yet, so that's a way to at least make those attributes universally available for even unknown room events. It matters, because read receipts can refer to any room event id and because we'll use event id's to filter out duplicate events in further commits; and missing timestamps used to break the timeline display (showing <> instead of <valid timestamps>).
|
|
|
|
Instead of QHash, use QVector< QPair<> > because it's more efficient and
we don't really need a hashmap functions, only direct iteration over the
list of event-to-receipt pairs. Also, iteration over QJsonObjects is
more efficient (and better conveys the intention) than collecting keys()
and then finding a value() for each of them. Also, fixed accidental
allocation of empty Receipt structures instead of reserving space for
them.
|
|
Room: Use reverse iterators internally to deal with read markers
|
|
Turns out that because the read marker is positioned _after_ the last read message, a reverse iterator models it much better than the usual one. This commit switches the internal representation to reverse iterators (externally, we operate in terms of event id's, still).
|
|
Make events traceable
|
|
|
|
A new hashmap, eventsIndex, is provided, that allows you to find the event in the timeline if you have eventId. This hashmap uses the fact that deque iterators don't invalidate upon insertion of elements to either end of the deque. Thanks to that, promoteReadMarker() and doAddNewMessageEvents() have been considerably simplified; also, it should be easier now to calculate event indices without rolling back and forth over the timeline.
|
|
|
|
|
|
Crop avatar to ensure it has exactly the wanted size; Fixes memory leak #45
|
|
Unread messages implementation in the library
|
|
|
|
|
|
Room::Private::member() filters out non-members of the room, which is not the right thing when adding messages from a person that left the room, e.g.
|
|
Thanks to @maralorn for pointing out.
|
|
Cleanup upon code inspection in CLion
|
|
|
|
|
|
|
|
The first change allows to use the read marker from QML (hint to Tensor). The second change is actually a fix for a case when markMessagesAsRead() is called with an iterator behind the last read event (in that case markMessagesAsRead() would post a receipt for that older event, which is not quite right).
|
|
These parts are either deprecated or just unlikely to be reused in the current form. Breaks Quaternion master as of now (it #includes logmessage.h).
|
|
associated with Event objects anyway
|
|
This code is useful for any client that uses the Room class and needs to display the list of room members. Also removed an unused #include.
|
|
|
|
These changes are most harmless; a no more used Private class removed, and an incorrect signal specification in connect() fixed. Also, one explicit #include has been added, just in case.
|
|
Kicking markMessagesAsRead() at each mouse move is still a bad idea - I'm looking at you Quaternion.
|
|
The implementation allows further extension to actually counting unread messages (in their Room::isEventNotable() sense - see the code) but so far just replicates what Quaternion previously provided. The only difference from the Quaternion implementation is that last own message is not marked as read immediately - so that we can allow the local user to send messages while staying with the read marker well above. This implies, though, that the read marker won't reset to the timeline bottom at any movement of the user - rather that it resets to the bottom of the current view (which is the ultimately correct behaviour, anyway).
|
|
Qt Creator turns out to be watching for "at :" substring in logs to detect messages that refer to files - which is not our case. Removing a comma fixes the alarm.
|
|
CMake tweaks
|
|
That list was bound to become outdated every now and then.
|
|
Qt5Core_DIR shows a path to the .cmake file's directory, which is a little too much information. The same change will be made in Quaternion, with the Qt prefix having additional usage in installation.
|
|
|
|
|
|
Room: added setLastReadEvent accessor and a signal for it; don't post receipts for own messages to the server
|
|
|
|
Room::markMessagesAsRead: use the iterator to the message, not after the message.
Room::setLastReadEvent: moved to protected
|
|
setLastReadEvent() is called in any case (read marks a stored in a hashmap so it's a constant time operation anyway); postReceipt() is now called for the nearest previous non-local message.
|
|
QJsonObject stock constructors are boring anyway - using QJsonObject::QJsonObject wasn't really necessary.
|
|
receipts for own messages to the server
As discussed with Matthew in #quaternion: https://matrix.to/#/!PCzUtxtOjUySxSelof:matrix.org/$14768896199130qcJqe:matrix.org
|