Don't form continuations from thread roots (#8166)
* Don't form continuations from thread roots * Only apply the continuation break in the main timeline
This commit is contained in:
@@ -25,6 +25,7 @@ import * as TestUtils from "react-dom/test-utils";
|
||||
|
||||
import { MatrixClientPeg } from '../../../src/MatrixClientPeg';
|
||||
import sdk from '../../skinned-sdk';
|
||||
import MessagePanel, { shouldFormContinuation } from "../../../src/components/structures/MessagePanel";
|
||||
import SettingsStore from "../../../src/settings/SettingsStore";
|
||||
import MatrixClientContext from "../../../src/contexts/MatrixClientContext";
|
||||
import RoomContext from "../../../src/contexts/RoomContext";
|
||||
@@ -32,8 +33,6 @@ import DMRoomMap from "../../../src/utils/DMRoomMap";
|
||||
import { UnwrappedEventTile } from "../../../src/components/views/rooms/EventTile";
|
||||
import * as TestUtilsMatrix from "../../test-utils";
|
||||
|
||||
const MessagePanel = sdk.getComponent('structures.MessagePanel');
|
||||
|
||||
let client;
|
||||
const room = new Matrix.Room("!roomId:server_name");
|
||||
|
||||
@@ -594,3 +593,25 @@ describe('MessagePanel', function() {
|
||||
expect(els.last().prop("events").length).toEqual(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldFormContinuation", () => {
|
||||
it("does not form continuations from thread roots", () => {
|
||||
const threadRoot = TestUtilsMatrix.mkMessage({
|
||||
event: true,
|
||||
room: "!room:id",
|
||||
user: "@user:id",
|
||||
msg: "Here is a thread",
|
||||
});
|
||||
jest.spyOn(threadRoot, "isThreadRoot", "get").mockReturnValue(true);
|
||||
|
||||
const message = TestUtilsMatrix.mkMessage({
|
||||
event: true,
|
||||
room: "!room:id",
|
||||
user: "@user:id",
|
||||
msg: "And here's another message in the main timeline",
|
||||
});
|
||||
|
||||
expect(shouldFormContinuation(threadRoot, message, false, true)).toEqual(false);
|
||||
expect(shouldFormContinuation(message, threadRoot, false, true)).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -191,7 +191,20 @@ export function mkEvent(opts: MakeEventProps): MatrixEvent {
|
||||
].indexOf(opts.type) !== -1) {
|
||||
event.state_key = "";
|
||||
}
|
||||
return opts.event ? new MatrixEvent(event) : event as unknown as MatrixEvent;
|
||||
|
||||
const mxEvent = opts.event ? new MatrixEvent(event) : event as unknown as MatrixEvent;
|
||||
if (!mxEvent.sender && opts.user && opts.room) {
|
||||
mxEvent.sender = {
|
||||
userId: opts.user,
|
||||
membership: "join",
|
||||
name: opts.user,
|
||||
rawDisplayName: opts.user,
|
||||
roomId: opts.room,
|
||||
getAvatarUrl: () => {},
|
||||
getMxcAvatarUrl: () => {},
|
||||
} as unknown as RoomMember;
|
||||
}
|
||||
return mxEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user