mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Merge pull request #3972 from matrix-org/jryans/missing-timeline-uisi
Check for timeline in pre-join UISI path
This commit is contained in:
commit
c0e88bede9
@ -1171,28 +1171,40 @@ const TimelinePanel = createReactClass({
|
|||||||
// get the user's membership at the last event by getting the timeline
|
// get the user's membership at the last event by getting the timeline
|
||||||
// that the event belongs to, and traversing the timeline looking for
|
// that the event belongs to, and traversing the timeline looking for
|
||||||
// that event, while keeping track of the user's membership
|
// that event, while keeping track of the user's membership
|
||||||
const lastEvent = events[events.length - 1];
|
let i;
|
||||||
const timeline = room.getTimelineForEvent(lastEvent.getId());
|
let userMembership = "leave";
|
||||||
const userMembershipEvent =
|
for (i = events.length - 1; i >= 0; i--) {
|
||||||
timeline.getState(EventTimeline.FORWARDS).getMember(userId);
|
const timeline = room.getTimelineForEvent(events[i].getId());
|
||||||
let userMembership = userMembershipEvent
|
if (!timeline) {
|
||||||
? userMembershipEvent.membership : "leave";
|
// Somehow, it seems to be possible for live events to not have
|
||||||
const timelineEvents = timeline.getEvents();
|
// a timeline, even though that should not happen. :(
|
||||||
for (let i = timelineEvents.length - 1; i >= 0; i--) {
|
// https://github.com/vector-im/riot-web/issues/12120
|
||||||
const event = timelineEvents[i];
|
console.warn(
|
||||||
if (event.getId() === lastEvent.getId()) {
|
`Event ${events[i].getId()} in room ${room.roomId} is live, ` +
|
||||||
// found the last event, so we can stop looking through the timeline
|
`but it does not have a timeline`,
|
||||||
break;
|
);
|
||||||
} else if (event.getStateKey() === userId
|
continue;
|
||||||
&& event.getType() === "m.room.member") {
|
|
||||||
const prevContent = event.getPrevContent();
|
|
||||||
userMembership = prevContent.membership || "leave";
|
|
||||||
}
|
}
|
||||||
|
const userMembershipEvent =
|
||||||
|
timeline.getState(EventTimeline.FORWARDS).getMember(userId);
|
||||||
|
userMembership = userMembershipEvent ? userMembershipEvent.membership : "leave";
|
||||||
|
const timelineEvents = timeline.getEvents();
|
||||||
|
for (let j = timelineEvents.length - 1; j >= 0; j--) {
|
||||||
|
const event = timelineEvents[j];
|
||||||
|
if (event.getId() === events[i].getId()) {
|
||||||
|
break;
|
||||||
|
} else if (event.getStateKey() === userId
|
||||||
|
&& event.getType() === "m.room.member") {
|
||||||
|
const prevContent = event.getPrevContent();
|
||||||
|
userMembership = prevContent.membership || "leave";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now go through the events that we have and find the first undecryptable
|
// now go through the rest of the events and find the first undecryptable
|
||||||
// one that was sent when the user wasn't in the room
|
// one that was sent when the user wasn't in the room
|
||||||
for (let i = events.length - 1; i >= 0; i--) {
|
for (; i >= 0; i--) {
|
||||||
const event = events[i];
|
const event = events[i];
|
||||||
if (event.getStateKey() === userId
|
if (event.getStateKey() === userId
|
||||||
&& event.getType() === "m.room.member") {
|
&& event.getType() === "m.room.member") {
|
||||||
|
Loading…
Reference in New Issue
Block a user