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

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

Open
turt2live opened this issue Mar 25, 2017 · 0 comments
Open
Labels

Comments

@turt2live
Copy link
Member

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:

matrix-js-sdk/src/sync.js

Lines 968 to 973 in 547333c

let room = client.store.getRoom(roomId);
let isBrandNewRoom = false;
if (!room) {
room = self.createRoom(roomId);
isBrandNewRoom = true;
}

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:

matrix-js-sdk/src/sync.js

Lines 91 to 105 in 547333c

SyncApi.prototype.createRoom = function(roomId) {
const client = this.client;
const room = new Room(roomId, {
pendingEventOrdering: this.opts.pendingEventOrdering,
timelineSupport: client.timelineSupport,
});
reEmit(client, room, ["Room.name", "Room.timeline", "Room.redaction",
"Room.receipt", "Room.tags",
"Room.timelineReset",
"Room.localEchoUpdated",
"Room.accountData",
]);
this._registerStateListeners(room);
return room;
};
)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant