matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

Rooms loaded from store don't appear to be firing events into the client

Open turt2live opened this issue 8 years ago • 0 comments

Sync responses containing rooms are converted using _mapSyncResponseToRoomArray in the SyncApi, currently. With this, rooms sometimes aren't sent off to reEmit to have their events reach the MatrixClient.

Here's the portion of code being mentioned from here on down: https://github.com/matrix-org/matrix-js-sdk/blob/547333c946e57dc618e144c0f8f6c2d84741d54a/src/sync.js#L968-L973

A room is first looked up using the backing store, which may be in memory, web, or something else. If the room is found, it is passed along just fine with isBrandNewRoom false. If the room is not found, however, it is created and marked as a new room.

(now referencing createRoom: https://github.com/matrix-org/matrix-js-sdk/blob/547333c946e57dc618e144c0f8f6c2d84741d54a/src/sync.js#L91-L105 )

When the room is created, it is sent off to reEmit so the events originating from the room end up also being raised in the client.

Because of getRoom's contract on the store, it can't return null in hopes that the sdk will build a new one for it (especially considering the store may be returning other information that causes the sdk to not update room state, because the room should already have it.

This means that rooms coming out of the store may not re-emit their events to the client, leading to interesting behaviour in various applications using the sdk.

Of course I may have completely missed something that has lead me in the wrong direction. Please point me back to the correct path if I've strayed too far.

turt2live avatar Mar 25 '17 23:03 turt2live