Distinguish room state and timeline events in embedded clients#4574
Merged
robintown merged 4 commits intomatrix-org:developfrom Jan 15, 2025
Merged
Distinguish room state and timeline events in embedded clients#4574robintown merged 4 commits intomatrix-org:developfrom
robintown merged 4 commits intomatrix-org:developfrom
Conversation
7d8eae7 to
a1eac0c
Compare
This change enables room widget clients to take advantage of the more reliable method of communicating room state over the widget API provided by a recent update to MSC2762.
a1eac0c to
4ff8c25
Compare
t3chguy
approved these changes
Dec 18, 2024
dbkr
approved these changes
Dec 18, 2024
toger5
approved these changes
Jan 13, 2025
Contributor
toger5
left a comment
There was a problem hiding this comment.
I approve this already. Can you still explain me why we don't need the await (or add it in case we need it)
toger5
reviewed
Jan 23, 2025
Contributor
toger5
left a comment
There was a problem hiding this comment.
@robintown Do you think those changes could make it work without needing changes on the rust sdk?
Comment on lines
-279
to
-299
| // Backfill the requested events | ||
| // We only get the most recent event for every type + state key combo, | ||
| // so it doesn't really matter what order we inject them in | ||
| await Promise.all( | ||
| this.capabilities.receiveState?.map(async ({ eventType, stateKey }) => { | ||
| const rawEvents = await this.widgetApi.readStateEvents(eventType, undefined, stateKey, [this.roomId]); | ||
| const events = rawEvents.map((rawEvent) => new MatrixEvent(rawEvent as Partial<IEvent>)); | ||
|
|
||
| if (this.syncApi instanceof SyncApi) { | ||
| // Passing undefined for `stateAfterEventList` allows will make `injectRoomEvents` run in legacy mode | ||
| // -> state events in `timelineEventList` will update the state. | ||
| await this.syncApi.injectRoomEvents(this.room!, undefined, events); | ||
| } else { | ||
| await this.syncApi!.injectRoomEvents(this.room!, events); // Sliding Sync | ||
| } | ||
| events.forEach((event) => { | ||
| this.emit(ClientEvent.Event, event); | ||
| logger.info(`Backfilled event ${event.getId()} ${event.getType()} ${event.getStateKey()}`); | ||
| }); | ||
| }) ?? [], | ||
| ); |
Contributor
There was a problem hiding this comment.
we could add this code back in case the driver does not support the update_state (or state_after) version.
|
|
||
| // Passing undefined for `stateAfterEventList` allows will make `injectRoomEvents` run in legacy mode | ||
| // -> state events in `timelineEventList` will update the state. | ||
| await this.syncApi.injectRoomEvents(this.room!, [], undefined, [event]); |
Contributor
There was a problem hiding this comment.
Use the state_after version is not supported use:
await this.syncApi.injectRoomEvents(this.room!, [], undefined, [event]); as before.
| // this.injectRoomEvents(this.room!, params.addToState ? [event] : [], params.addToTimeline ? [event] : []); | ||
| // } | ||
| // ``` | ||
| await this.syncApi!.injectRoomEvents(this.room!, [], [event]); // Sliding Sync |
Contributor
There was a problem hiding this comment.
also use this if the version is not supported.
RiotRobot
pushed a commit
that referenced
this pull request
Jan 27, 2025
hughns
pushed a commit
that referenced
this pull request
Jan 27, 2025
* Distinguish room state and timeline events in embedded clients This change enables room widget clients to take advantage of the more reliable method of communicating room state over the widget API provided by a recent update to MSC2762. * Add missing awaits * Upgrade matrix-widget-api
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change enables room widget clients to take advantage of the more reliable method of communicating room state over the widget API provided by this update to MSC2762.
Depends on matrix-org/matrix-widget-api#116