-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Distinguish room state and timeline events in embedded clients #4574
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
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.
I approve this already. Can you still explain me why we don't need the await (or add it in case we need it)
bdd4d82
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.
@robintown Do you think those changes could make it work without needing changes on the rust sdk?
// 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()}`); | ||
}); | ||
}) ?? [], | ||
); |
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.
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]); |
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.
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 |
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.
also use this if the version is not supported.
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