Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Don't consider threads for breaking continuation until actually created #8581

Merged
merged 4 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/structures/MessagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ const groupedEvents = [
EventType.RoomPinnedEvents,
];

function hasThreadSummary(event: MatrixEvent): boolean {
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
return event.isThreadRoot && event?.getThread().length && !!event.getThread().replyToEvent;
robintown marked this conversation as resolved.
Show resolved Hide resolved
}

// check if there is a previous event and it has the same sender as this event
// and the types are the same/is in continuedTypes and the time between them is <= CONTINUATION_MAX_INTERVAL
export function shouldFormContinuation(
Expand Down Expand Up @@ -96,7 +100,7 @@ export function shouldFormContinuation(

// Thread summaries in the main timeline should break up a continuation on both sides
if (threadsEnabled &&
(mxEvent.isThreadRoot || prevEvent.isThreadRoot) &&
(hasThreadSummary(mxEvent) || hasThreadSummary(prevEvent)) &&
timelineRenderingType !== TimelineRenderingType.Thread
) {
return false;
Expand Down
9 changes: 8 additions & 1 deletion test/components/structures/MessagePanel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ describe('MessagePanel', function() {
});

describe("shouldFormContinuation", () => {
it("does not form continuations from thread roots", () => {
it("does not form continuations from thread roots which have summaries", () => {
const message1 = TestUtilsMatrix.mkMessage({
event: true,
room: "!room:id",
Expand Down Expand Up @@ -730,6 +730,13 @@ describe("shouldFormContinuation", () => {
});

expect(shouldFormContinuation(message1, message2, false, true)).toEqual(true);
expect(shouldFormContinuation(message2, threadRoot, false, true)).toEqual(true);
expect(shouldFormContinuation(threadRoot, message3, false, true)).toEqual(true);

const thread = {};
thread.length = 1;
thread.replyToEvent = {};
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
jest.spyOn(threadRoot, "getThread").mockReturnValue(thread);
expect(shouldFormContinuation(message2, threadRoot, false, true)).toEqual(false);
expect(shouldFormContinuation(threadRoot, message3, false, true)).toEqual(false);
});
Expand Down