Don't consider threads for breaking continuation until actually created (#8581)
* Don't consider threads for breaking continuation until they've actually been created * Update tests * Make hasThreadSummary null thread safe * Apply feedback from pr review
This commit is contained in:
parent
fbbb9c27ba
commit
59b9d1e818
3 changed files with 15 additions and 2 deletions
|
@ -56,6 +56,7 @@ import { getEventDisplayInfo } from "../../utils/EventRenderingUtils";
|
||||||
import { IReadReceiptInfo } from "../views/rooms/ReadReceiptMarker";
|
import { IReadReceiptInfo } from "../views/rooms/ReadReceiptMarker";
|
||||||
import { haveRendererForEvent } from "../../events/EventTileFactory";
|
import { haveRendererForEvent } from "../../events/EventTileFactory";
|
||||||
import { editorRoomKey } from "../../Editing";
|
import { editorRoomKey } from "../../Editing";
|
||||||
|
import { hasThreadSummary } from "../../utils/EventUtils";
|
||||||
|
|
||||||
const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
||||||
const continuedTypes = [EventType.Sticker, EventType.RoomMessage];
|
const continuedTypes = [EventType.Sticker, EventType.RoomMessage];
|
||||||
|
@ -96,7 +97,7 @@ export function shouldFormContinuation(
|
||||||
|
|
||||||
// Thread summaries in the main timeline should break up a continuation on both sides
|
// Thread summaries in the main timeline should break up a continuation on both sides
|
||||||
if (threadsEnabled &&
|
if (threadsEnabled &&
|
||||||
(mxEvent.isThreadRoot || prevEvent.isThreadRoot) &&
|
(hasThreadSummary(mxEvent) || hasThreadSummary(prevEvent)) &&
|
||||||
timelineRenderingType !== TimelineRenderingType.Thread
|
timelineRenderingType !== TimelineRenderingType.Thread
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -280,3 +280,7 @@ export function canForward(event: MatrixEvent): boolean {
|
||||||
M_POLL_START.matches(event.getType())
|
M_POLL_START.matches(event.getType())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hasThreadSummary(event: MatrixEvent): boolean {
|
||||||
|
return event.isThreadRoot && event.getThread()?.length && !!event.getThread().replyToEvent;
|
||||||
|
}
|
||||||
|
|
|
@ -699,7 +699,7 @@ describe('MessagePanel', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("shouldFormContinuation", () => {
|
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({
|
const message1 = TestUtilsMatrix.mkMessage({
|
||||||
event: true,
|
event: true,
|
||||||
room: "!room:id",
|
room: "!room:id",
|
||||||
|
@ -730,6 +730,14 @@ describe("shouldFormContinuation", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(shouldFormContinuation(message1, message2, false, true)).toEqual(true);
|
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 = {
|
||||||
|
length: 1,
|
||||||
|
replyToEvent: {},
|
||||||
|
};
|
||||||
|
jest.spyOn(threadRoot, "getThread").mockReturnValue(thread);
|
||||||
expect(shouldFormContinuation(message2, threadRoot, false, true)).toEqual(false);
|
expect(shouldFormContinuation(message2, threadRoot, false, true)).toEqual(false);
|
||||||
expect(shouldFormContinuation(threadRoot, message3, false, true)).toEqual(false);
|
expect(shouldFormContinuation(threadRoot, message3, false, true)).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue