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

feat(WidgetDriver): Send state from state sync and not from timeline to widget #4254

Merged
merged 6 commits into from
Nov 14, 2024

Conversation

toger5
Copy link
Contributor

@toger5 toger5 commented Nov 12, 2024

This PR changes the source of messages send to the widget. Instead of using:
let handle = self.room.add_event_handler(move |raw: Raw<AnySyncTimelineEvent>| {})
which listens to all events form the timeline section of the sync, we use two listeners for state and message like:
let handle = self.room.add_event_handler(move |raw: Raw<AnySyncStateEvent>| {})
And
let handle = self.room.add_event_handler(move |raw: Raw<AnySyncMessageLikeEvent>| {})

AnySyncStateEvent should only get events from the state block of the SSS response.
and AnySyncMessageLikeEvent all the message like events from the timeline block.

This makes the behaviour equivalent to: element-hq/element-web#28422

  • Public API changes documented in changelogs (optional)

Signed-off-by:

@toger5 toger5 force-pushed the toger5/widget-driver-state-after branch from ca4df5f to 2380af6 Compare November 13, 2024 08:54
@toger5 toger5 changed the base branch from toger5/widget-driver-matrix-api-errors to main November 13, 2024 08:54
@toger5 toger5 changed the title Toger5/widget-driver-state-after feat(WidgetDriver): Send state from state sync and not from timeline to widget Nov 13, 2024
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.90%. Comparing base (ab61077) to head (ee7c80c).
Report is 42 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4254      +/-   ##
==========================================
+ Coverage   84.87%   84.90%   +0.03%     
==========================================
  Files         274      274              
  Lines       29712    29719       +7     
==========================================
+ Hits        25218    25233      +15     
+ Misses       4494     4486       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@toger5 toger5 marked this pull request as ready for review November 13, 2024 15:34
@toger5 toger5 requested a review from a team as a code owner November 13, 2024 15:34
@toger5 toger5 requested review from stefanceriu and removed request for a team November 13, 2024 15:34
crates/matrix-sdk/src/widget/matrix.rs Outdated Show resolved Hide resolved
crates/matrix-sdk/src/widget/matrix.rs Outdated Show resolved Hide resolved
toger5 and others added 2 commits November 14, 2024 13:15
Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
Signed-off-by: Timo <16718859+toger5@users.noreply.github.com>
Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
Signed-off-by: Timo <16718859+toger5@users.noreply.github.com>
Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@stefanceriu stefanceriu enabled auto-merge (squash) November 14, 2024 12:17
@toger5
Copy link
Contributor Author

toger5 commented Nov 14, 2024

@stefanceriu @bnjbvr, I asked this in one of the room but it does not hurt to ask for double confirmation that this comment is actually what is happening:

// Get only all state events from the state section of the sync.
let handle_state = self.room.add_event_handler(move |raw: Raw<AnySyncStateEvent>| {
    let _ = tx.send(attach_room_id(raw.cast_ref(), &room_id));
    async {}
});

@stefanceriu
Copy link
Member

Looks like that to me, yes:

state_events: &[Raw<AnySyncStateEvent>],

@stefanceriu
Copy link
Member

Confirmed with @bnjbvr that this is indeed correct, will go ahead and merge it 👍

@stefanceriu stefanceriu merged commit 7aa930b into main Nov 14, 2024
40 checks passed
@stefanceriu stefanceriu deleted the toger5/widget-driver-state-after branch November 14, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants