This commit is contained in:
Bruno Windels 2021-05-06 15:27:32 +02:00
parent 7e450071b1
commit 030b6837ef

View file

@ -32,11 +32,11 @@ function applySyncResponse(data, roomResponse, membership, ownUserId) {
if (roomResponse.summary) { if (roomResponse.summary) {
data = updateSummary(data, roomResponse.summary); data = updateSummary(data, roomResponse.summary);
} }
let needKickDetails = false; let hasLeft = false;
if (membership !== data.membership) { if (membership !== data.membership) {
data = data.cloneIfNeeded(); data = data.cloneIfNeeded();
data.membership = membership; data.membership = membership;
needKickDetails = membership === "leave" || membership === "ban"; hasLeft = membership === "leave" || membership === "ban";
} }
if (roomResponse.account_data) { if (roomResponse.account_data) {
data = roomResponse.account_data.events.reduce(processRoomAccountData, data); data = roomResponse.account_data.events.reduce(processRoomAccountData, data);
@ -45,10 +45,10 @@ function applySyncResponse(data, roomResponse, membership, ownUserId) {
// state comes before timeline // state comes before timeline
if (Array.isArray(stateEvents)) { if (Array.isArray(stateEvents)) {
data = stateEvents.reduce((data, event) => { data = stateEvents.reduce((data, event) => {
if (needKickDetails) { if (hasLeft) {
data = findKickDetails(data, event, ownUserId); data = findKickDetails(data, event, ownUserId);
} }
return processStateEvent(data, event, ownUserId, needKickDetails); return processStateEvent(data, event, ownUserId, hasLeft);
}, data); }, data);
} }
const timelineEvents = roomResponse?.timeline?.events; const timelineEvents = roomResponse?.timeline?.events;
@ -58,7 +58,7 @@ function applySyncResponse(data, roomResponse, membership, ownUserId) {
if (Array.isArray(timelineEvents)) { if (Array.isArray(timelineEvents)) {
data = timelineEvents.reduce((data, event) => { data = timelineEvents.reduce((data, event) => {
if (typeof event.state_key === "string") { if (typeof event.state_key === "string") {
if (needKickDetails) { if (hasLeft) {
data = findKickDetails(data, event, ownUserId); data = findKickDetails(data, event, ownUserId);
} }
return processStateEvent(data, event); return processStateEvent(data, event);