Fix regression around haveRendererForEvent for hidden events (#8379)

This commit is contained in:
Michael Telatynski 2022-04-21 17:57:08 +01:00 committed by GitHub
parent 399ac618c7
commit bbe0c945d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 9 deletions

View file

@ -452,14 +452,6 @@ export default class MessagePanel extends React.Component<IProps, IState> {
} }
} }
/* check the scroll state and send out pagination requests if necessary.
*/
public checkFillState(): void {
if (this.scrollPanel.current) {
this.scrollPanel.current.checkFillState();
}
}
private isUnmounting = (): boolean => { private isUnmounting = (): boolean => {
return !this.isMounted; return !this.isMounted;
}; };

View file

@ -393,6 +393,8 @@ export function haveRendererForEvent(mxEvent: MatrixEvent, showHiddenEvents: boo
return hasText(mxEvent, showHiddenEvents); return hasText(mxEvent, showHiddenEvents);
} else if (handler === STATE_EVENT_TILE_TYPES[EventType.RoomCreate]) { } else if (handler === STATE_EVENT_TILE_TYPES[EventType.RoomCreate]) {
return Boolean(mxEvent.getContent()['predecessor']); return Boolean(mxEvent.getContent()['predecessor']);
} else if (handler === JSONEventFactory) {
return false;
} else { } else {
return true; return true;
} }

View file

@ -44,6 +44,8 @@ class WrappedMessagePanel extends React.Component {
callEventGroupers = new Map(); callEventGroupers = new Map();
render() { render() {
const { showHiddenEvents, ...props } = this.props;
const roomContext = { const roomContext = {
room, room,
roomId: room.roomId, roomId: room.roomId,
@ -54,13 +56,14 @@ class WrappedMessagePanel extends React.Component {
showJoinLeaves: false, showJoinLeaves: false,
showAvatarChanges: false, showAvatarChanges: false,
showDisplaynameChanges: true, showDisplaynameChanges: true,
showHiddenEvents,
}; };
return <MatrixClientContext.Provider value={client}> return <MatrixClientContext.Provider value={client}>
<RoomContext.Provider value={roomContext}> <RoomContext.Provider value={roomContext}>
<MessagePanel <MessagePanel
room={room} room={room}
{...this.props} {...props}
resizeNotifier={this.resizeNotifier} resizeNotifier={this.resizeNotifier}
callEventGroupers={this.callEventGroupers} callEventGroupers={this.callEventGroupers}
/> />
@ -633,6 +636,40 @@ describe('MessagePanel', function() {
expect(settingsSpy).not.toHaveBeenCalledWith("showHiddenEventsInTimeline"); expect(settingsSpy).not.toHaveBeenCalledWith("showHiddenEventsInTimeline");
settingsSpy.mockRestore(); settingsSpy.mockRestore();
}); });
it("should group hidden event reactions into an event list summary", () => {
const events = [
TestUtilsMatrix.mkEvent({
event: true,
type: "m.reaction",
room: "!room:id",
user: "@user:id",
content: {},
ts: 1,
}),
TestUtilsMatrix.mkEvent({
event: true,
type: "m.reaction",
room: "!room:id",
user: "@user:id",
content: {},
ts: 2,
}),
TestUtilsMatrix.mkEvent({
event: true,
type: "m.reaction",
room: "!room:id",
user: "@user:id",
content: {},
ts: 3,
}),
];
const res = mount(<WrappedMessagePanel showHiddenEvents={true} events={events} />);
const els = res.find("EventListSummary");
expect(els.length).toEqual(1);
expect(els.prop("events").length).toEqual(3);
});
}); });
describe("shouldFormContinuation", () => { describe("shouldFormContinuation", () => {