-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Only feed state events to widgets if we believe they update the state #28422
base: develop
Are you sure you want to change the base?
Conversation
As part of the effort to make room state more reliable, we're looking at changing how state is communicated to widgets. Rather than passing all state events from the timeline through (and forcing the widget to assume that they belong to the server's view of the room state), let's try passing only those state events through that we believe actually belong to the server's view of the room state. When combined with a matrix-js-sdk that supports MSC4222, this improves the reliability of state tracking for widgets. We would like to later explore a solution that has a separate 'state update' widget action in addition to the generic 'incoming timeline event' widget action, to make the widget API better reflect the shape of the data sources that drive it (like the sync responses of Simplified Sliding Sync or MSC4222).
@@ -463,15 +471,33 @@ export class StopGapWidget extends EventEmitter { | |||
|
|||
this.client.off(ClientEvent.Event, this.onEvent); |
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.
Change to RoomEvent.Timeline
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.
Can you help me understand why RoomEvent.Timeline
would be more appropriate here? I'm looking at:
/**
* Fires whenever the SDK receives a new event.
* <p>
* This is only fired for live events received via /sync - it is not fired for
* events received over context, search, or pagination APIs.
*
* @param event - The matrix event which caused this event to fire.
* @example
* ```
* matrixClient.on("event", function(event){
* var sender = event.getSender();
* });
* ```
*/
[ClientEvent.Event]: (event: MatrixEvent) => void;
versus
/**
* Fires whenever the timeline in a room is updated.
* @param event - The matrix event which caused this event to fire.
* @param room - The room, if any, whose timeline was updated.
* @param toStartOfTimeline - True if this event was added to the start
* @param removed - True if this event has just been removed from the timeline
* (beginning; oldest) of the timeline e.g. due to pagination.
*
* @param data - more data about the event
*
* @example
* ```
* matrixClient.on("Room.timeline",
* function(event, room, toStartOfTimeline, removed, data) {
* if (!toStartOfTimeline && data.liveEvent) {
* var messageToAppend = room.timeline.[room.timeline.length - 1];
* }
* });
* ```
*/
[RoomEvent.Timeline]: (
event: MatrixEvent,
room: Room | undefined,
toStartOfTimeline: boolean | undefined,
removed: boolean,
data: IRoomTimelineData,
) => void;
and from these comments it sounds like ClientEvent.Event
, receiving new live events down /sync, is exactly what we want.
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.
ClientEvent.Event
fires on every single event the SDK ever sees, state, account data, presence, all before those events are processed and without any metadata on whether that event is state which should be applied (state_after
), or state which should be ignored (timeline
).
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.
Right okay, and we don't seem to require any metadata or processing in this spot
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 do if we want to tell the embedded client if the event is in the timeline or state, isState()
doesn't tell you that.
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.
For now we're not yet trying to tell widgets that. This is deliberately a very blunt, "filter all state events out of the timeline and then finally send through just those state events that cause a RoomStateEvent.Events
" change. (which is why it's in draft)
should the js-sdk bump to support 4222 also be part of this PR? So that we have a fully supported netlify build? |
#28398 is already using that branch matching so please do not interrupt it as it'll mean it'll take longer for the MSC4222 support to land |
Please do not do that, my PR is the minimum required to retain compatibility with the js-sdk changes, any larger than that and it'll increase risk of landing it & also make review take longer than it needs to. |
As part of the effort to make room state more reliable, we're looking at changing how state is communicated to widgets. Rather than passing all state events from the timeline through (and forcing the widget to assume that they belong to the server's view of the room state), let's try passing only those state events through that we believe actually belong to the server's view of the room state. When combined with a matrix-js-sdk that supports MSC4222, this improves the reliability of state tracking for widgets.
We would like to later explore a solution that has a separate 'state update' widget action in addition to the generic 'incoming timeline event' widget action, to make the widget API better reflect the shape of the data sources that drive it (like the sync responses of Simplified Sliding Sync or MSC4222).