Skip to content
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

Post Event PendingEventItems #861

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

nvrWhere
Copy link
Collaborator

@nvrWhere nvrWhere commented Jan 25, 2025

Always return pending event items when posting events rather than transaction IDs

Also add a future for about to merge as it's useful when rearranging a timeline model (we need to know where the pending event was in the timeline to make sure it can be moved to the right place and this isn't available after merge)

@@ -850,7 +850,7 @@ public Q_SLOTS:
/// The event is about to be appended to the list of pending events
void pendingEventAboutToAdd(Quotient::RoomEvent* event);
/// An event has been appended to the list of pending events
void pendingEventAdded(const Quotient::RoomEvent* event);
void pendingEventAdded(const PendingEventItem& pendingItem);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's a good idea; for one, you cannot use a queued connection with this signal because a reference cannot be copied; and besides, this reference is at risk of dangling if any slot connected to pendingEventAdded causes adding another pending event to the same room (I stumbled over it when writing Quotest, some time ago). At the very least, these caveats should be in the signal documentation.

//!
//! The future will get finished just before this pending item is merged into its remote
//! counterpart that comes with /sync. The pending item will always be in ReachedServer state.
//! The future result has type implicitly convertible to std::pair with a `const RoomEvent&` and an `int`.
about_to_merge_future_type whenAboutToMerged() const { return _aboutToMergePromise.future(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have code that would use it? Or at least can you give an idea of code that would use it? Futures are generally heavier than signal-slot connections.

@KitsuneRal KitsuneRal added the enhancement A feature or change request for the library label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or change request for the library
Projects
Status: In work
Development

Successfully merging this pull request may close these issues.

2 participants