-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create ThreadView to track threads in a room #825
base: dev
Are you sure you want to change the base?
Conversation
I happen to have the answer to the question about having the same event in several timelines. We really should separate the concerns of storing events and referencing them. Each room should have its own storage of events (could be unique pointers because we rarely delete events atm, but we could also use shared pointers or Qt's shared data paradigm); any event container (state or timeline) would then simply refer to the event. Event ids are obvious keys for the hash map storage, to find them whenever they are mentioned in sync/history batches. That really is it. It cannot be implemented without breaking the API because |
As it so happens this is exactly what I was thinking. |
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments on the current code.
Thread* getThread(const QString& threadRootId) const; | ||
|
||
private: | ||
std::vector<std::unique_ptr<Thread>> _threads; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why std::unique_ptr
and not Thread
itself? I don't see polymorphism being involved, and I'm not sure what other reasons might require dynamic allocation of a structure the size of 4 pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So currently the Thread object is not copy assignable by design so this makes erasing possible. Maybe however this is just a sign that std::vector
is not the right container
This is some initial work to make supporting threads easier. As part of the thread spec the root event gets some aggregation in the unsigned of the root event. However this is not automatically sync when the thread is started or a new message is added so we can't just rely on it's presence.
This leaves us with 2 options:
This PR does number 2.
A new
ThreadView
is created which holds a list ofThread
objects each representing the info for a single thread. As new events are added to the timeline each one is now checked to see if it is threaded and if so aThread
is either updated with the info as required or created if it is a previously unknown thread.This is intentionally a very simple start, I intend at some point for it to contain it's own timeline but before we can do that we would have to decide how we want to manage having the same event in multiple timelines.