From a70f11704f4191e2b84a07f69a3f5982ef6fbeb3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 26 Apr 2022 09:30:36 +0100 Subject: [PATCH] Don't form continuations on either side of a thread root (#8408) --- src/components/structures/MessagePanel.tsx | 10 +++++--- .../structures/MessagePanel-test.js | 23 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 8600da9047..38d18e92f7 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -92,9 +92,13 @@ export function shouldFormContinuation( mxEvent.sender.name !== prevEvent.sender.name || mxEvent.sender.getMxcAvatarUrl() !== prevEvent.sender.getMxcAvatarUrl()) return false; - // Thread summaries in the main timeline should break up a continuation - if (threadsEnabled && prevEvent.isThreadRoot && - timelineRenderingType !== TimelineRenderingType.Thread) return false; + // Thread summaries in the main timeline should break up a continuation on both sides + if (threadsEnabled && + (mxEvent.isThreadRoot || prevEvent.isThreadRoot) && + timelineRenderingType !== TimelineRenderingType.Thread + ) { + return false; + } // if we don't have tile for previous event then it was shown by showHiddenEvents and has no SenderProfile if (!haveRendererForEvent(prevEvent, showHiddenEvents)) return false; diff --git a/test/components/structures/MessagePanel-test.js b/test/components/structures/MessagePanel-test.js index eca8c39bec..4b2d549936 100644 --- a/test/components/structures/MessagePanel-test.js +++ b/test/components/structures/MessagePanel-test.js @@ -674,6 +674,20 @@ describe('MessagePanel', function() { describe("shouldFormContinuation", () => { it("does not form continuations from thread roots", () => { + const message1 = TestUtilsMatrix.mkMessage({ + event: true, + room: "!room:id", + user: "@user:id", + msg: "Here is a message in the main timeline", + }); + + const message2 = TestUtilsMatrix.mkMessage({ + event: true, + room: "!room:id", + user: "@user:id", + msg: "And here's another message in the main timeline", + }); + const threadRoot = TestUtilsMatrix.mkMessage({ event: true, room: "!room:id", @@ -682,14 +696,15 @@ describe("shouldFormContinuation", () => { }); jest.spyOn(threadRoot, "isThreadRoot", "get").mockReturnValue(true); - const message = TestUtilsMatrix.mkMessage({ + const message3 = TestUtilsMatrix.mkMessage({ event: true, room: "!room:id", user: "@user:id", - msg: "And here's another message in the main timeline", + msg: "And here's another message in the main timeline after the thread root", }); - expect(shouldFormContinuation(threadRoot, message, false, true)).toEqual(false); - expect(shouldFormContinuation(message, threadRoot, false, true)).toEqual(true); + expect(shouldFormContinuation(message1, message2, false, true)).toEqual(true); + expect(shouldFormContinuation(message2, threadRoot, false, true)).toEqual(false); + expect(shouldFormContinuation(threadRoot, message3, false, true)).toEqual(false); }); });