1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

emit self-membership event at end of handling sync update

otherwise the room state isn't updated yet (and we can't for
example distinguish a leave from a kick)

this is only used for updating the UI,
seems safe to emit this event at a later point
This commit is contained in:
Bruno Windels
2019-04-16 17:16:24 +02:00
parent 14973a35c2
commit dcaea98e33

View File

@@ -1104,7 +1104,6 @@ SyncApi.prototype._processSyncResponse = async function(
const stateEvents = const stateEvents =
self._mapSyncEventsFormat(inviteObj.invite_state, room); self._mapSyncEventsFormat(inviteObj.invite_state, room);
room.updateMyMembership("invite");
self._processRoomEvents(room, stateEvents); self._processRoomEvents(room, stateEvents);
if (inviteObj.isBrandNewRoom) { if (inviteObj.isBrandNewRoom) {
room.recalculate(); room.recalculate();
@@ -1114,6 +1113,7 @@ SyncApi.prototype._processSyncResponse = async function(
stateEvents.forEach(function(e) { stateEvents.forEach(function(e) {
client.emit("event", e); client.emit("event", e);
}); });
room.updateMyMembership("invite");
}); });
// Handle joins // Handle joins
@@ -1143,8 +1143,6 @@ SyncApi.prototype._processSyncResponse = async function(
} }
} }
room.updateMyMembership("join");
joinObj.timeline = joinObj.timeline || {}; joinObj.timeline = joinObj.timeline || {};
if (joinObj.isBrandNewRoom) { if (joinObj.isBrandNewRoom) {
@@ -1257,6 +1255,8 @@ SyncApi.prototype._processSyncResponse = async function(
accountDataEvents.forEach(function(e) { accountDataEvents.forEach(function(e) {
client.emit("event", e); client.emit("event", e);
}); });
room.updateMyMembership("join");
}); });
// Handle leaves (e.g. kicked rooms) // Handle leaves (e.g. kicked rooms)
@@ -1269,8 +1269,6 @@ SyncApi.prototype._processSyncResponse = async function(
const accountDataEvents = const accountDataEvents =
self._mapSyncEventsFormat(leaveObj.account_data); self._mapSyncEventsFormat(leaveObj.account_data);
room.updateMyMembership("leave");
self._processRoomEvents(room, stateEvents, timelineEvents); self._processRoomEvents(room, stateEvents, timelineEvents);
room.addAccountData(accountDataEvents); room.addAccountData(accountDataEvents);
@@ -1291,6 +1289,8 @@ SyncApi.prototype._processSyncResponse = async function(
accountDataEvents.forEach(function(e) { accountDataEvents.forEach(function(e) {
client.emit("event", e); client.emit("event", e);
}); });
room.updateMyMembership("leave");
}); });
// update the notification timeline, if appropriate. // update the notification timeline, if appropriate.