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

Commit a70f117

Browse files
authored
Don't form continuations on either side of a thread root (#8408)
1 parent f85e178 commit a70f117

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/components/structures/MessagePanel.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,13 @@ export function shouldFormContinuation(
9292
mxEvent.sender.name !== prevEvent.sender.name ||
9393
mxEvent.sender.getMxcAvatarUrl() !== prevEvent.sender.getMxcAvatarUrl()) return false;
9494

95-
// Thread summaries in the main timeline should break up a continuation
96-
if (threadsEnabled && prevEvent.isThreadRoot &&
97-
timelineRenderingType !== TimelineRenderingType.Thread) return false;
95+
// Thread summaries in the main timeline should break up a continuation on both sides
96+
if (threadsEnabled &&
97+
(mxEvent.isThreadRoot || prevEvent.isThreadRoot) &&
98+
timelineRenderingType !== TimelineRenderingType.Thread
99+
) {
100+
return false;
101+
}
98102

99103
// if we don't have tile for previous event then it was shown by showHiddenEvents and has no SenderProfile
100104
if (!haveRendererForEvent(prevEvent, showHiddenEvents)) return false;

test/components/structures/MessagePanel-test.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,20 @@ describe('MessagePanel', function() {
674674

675675
describe("shouldFormContinuation", () => {
676676
it("does not form continuations from thread roots", () => {
677+
const message1 = TestUtilsMatrix.mkMessage({
678+
event: true,
679+
room: "!room:id",
680+
user: "@user:id",
681+
msg: "Here is a message in the main timeline",
682+
});
683+
684+
const message2 = TestUtilsMatrix.mkMessage({
685+
event: true,
686+
room: "!room:id",
687+
user: "@user:id",
688+
msg: "And here's another message in the main timeline",
689+
});
690+
677691
const threadRoot = TestUtilsMatrix.mkMessage({
678692
event: true,
679693
room: "!room:id",
@@ -682,14 +696,15 @@ describe("shouldFormContinuation", () => {
682696
});
683697
jest.spyOn(threadRoot, "isThreadRoot", "get").mockReturnValue(true);
684698

685-
const message = TestUtilsMatrix.mkMessage({
699+
const message3 = TestUtilsMatrix.mkMessage({
686700
event: true,
687701
room: "!room:id",
688702
user: "@user:id",
689-
msg: "And here's another message in the main timeline",
703+
msg: "And here's another message in the main timeline after the thread root",
690704
});
691705

692-
expect(shouldFormContinuation(threadRoot, message, false, true)).toEqual(false);
693-
expect(shouldFormContinuation(message, threadRoot, false, true)).toEqual(true);
706+
expect(shouldFormContinuation(message1, message2, false, true)).toEqual(true);
707+
expect(shouldFormContinuation(message2, threadRoot, false, true)).toEqual(false);
708+
expect(shouldFormContinuation(threadRoot, message3, false, true)).toEqual(false);
694709
});
695710
});

0 commit comments

Comments
 (0)