You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Fix how Room::eventShouldLiveIn
handles replies to unknown parents (#3615)
* Add warning * Fix how Room::eventShouldLiveIn handles replies to unknown parents
This commit is contained in:
committed by
GitHub
parent
38c3abb364
commit
6b018b6927
@ -3018,6 +3018,14 @@ describe("Room", function () {
|
||||
expect(responseRelations![0][1].size).toEqual(1);
|
||||
expect(responseRelations![0][1].has(threadReaction)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("a non-thread reply to an unknown parent event should live in the main timeline only", async () => {
|
||||
const message = mkMessage(); // we do not add this message to any timelines
|
||||
const reply = mkReply(message);
|
||||
|
||||
expect(room.eventShouldLiveIn(reply).shouldLiveInRoom).toBeTruthy();
|
||||
expect(room.eventShouldLiveIn(reply).shouldLiveInThread).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("getEventReadUpTo()", () => {
|
||||
|
@ -984,11 +984,20 @@ export class EventTimelineSet extends TypedEventEmitter<EmittedEvents, EventTime
|
||||
);
|
||||
}
|
||||
|
||||
const { threadId, shouldLiveInRoom } = this.room.eventShouldLiveIn(event);
|
||||
const { threadId, shouldLiveInRoom, shouldLiveInThread } = this.room.eventShouldLiveIn(event);
|
||||
|
||||
if (this.thread) {
|
||||
return this.thread.id === threadId;
|
||||
}
|
||||
|
||||
if (!shouldLiveInRoom && !shouldLiveInThread) {
|
||||
logger.warn(
|
||||
`EventTimelineSet:canContain event encountered which cannot be added to any timeline roomId=${
|
||||
this.room?.roomId
|
||||
} eventId=${event.getId()} threadId=${event.threadRootId}`,
|
||||
);
|
||||
}
|
||||
|
||||
return shouldLiveInRoom;
|
||||
}
|
||||
}
|
||||
|
@ -2157,7 +2157,10 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
||||
};
|
||||
}
|
||||
|
||||
if (!parentEventId) {
|
||||
// Due to replies not being typical relations and being used as fallbacks for threads relations
|
||||
// If we bypass the if case above then we know we are not a thread, so if we are still a reply
|
||||
// then we know that we must be in the main timeline. Same goes if we have no associated parent event.
|
||||
if (!parentEventId || !!event.replyEventId) {
|
||||
return {
|
||||
shouldLiveInRoom: true,
|
||||
shouldLiveInThread: false,
|
||||
|
Reference in New Issue
Block a user