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:
Robin 2022-03-26 18:06:25 -04:00 committed by GitHub
parent 6c69f3e3b6
commit 1e060fed84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 11 deletions

View file

@ -69,6 +69,7 @@ export function shouldFormContinuation(
prevEvent: MatrixEvent,
mxEvent: MatrixEvent,
showHiddenEvents: boolean,
threadsEnabled: boolean,
timelineRenderingType?: TimelineRenderingType,
): boolean {
if (timelineRenderingType === TimelineRenderingType.ThreadsList) return false;
@ -90,6 +91,10 @@ 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;
// if we don't have tile for previous event then it was shown by showHiddenEvents and has no SenderProfile
if (!haveTileForEvent(prevEvent, showHiddenEvents)) return false;
@ -241,6 +246,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
private readReceiptsByUserId: Record<string, IReadReceiptForUser> = {};
private readonly showHiddenEventsInTimeline: boolean;
private readonly threadsEnabled: boolean;
private isMounted = false;
private readMarkerNode = createRef<HTMLLIElement>();
@ -264,10 +270,11 @@ export default class MessagePanel extends React.Component<IProps, IState> {
hideSender: this.shouldHideSender(),
};
// Cache hidden events setting on mount since Settings is expensive to
// query, and we check this in a hot code path. This is also cached in
// our RoomContext, however we still need a fallback for roomless MessagePanels.
// Cache these settings on mount since Settings is expensive to query,
// and we check this in a hot code path. This is also cached in our
// RoomContext, however we still need a fallback for roomless MessagePanels.
this.showHiddenEventsInTimeline = SettingsStore.getValue("showHiddenEventsInTimeline");
this.threadsEnabled = SettingsStore.getValue("feature_thread");
this.showTypingNotificationsWatcherRef =
SettingsStore.watchSetting("showTypingNotifications", null, this.onShowTypingNotificationsChange);
@ -465,7 +472,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
// TODO: Implement granular (per-room) hide options
public shouldShowEvent(mxEv: MatrixEvent, forceHideEvents = false): boolean {
if (this.props.hideThreadedMessages && SettingsStore.getValue("feature_thread")) {
if (this.props.hideThreadedMessages && this.threadsEnabled) {
if (mxEv.isThreadRelation) {
return false;
}
@ -744,12 +751,16 @@ export default class MessagePanel extends React.Component<IProps, IState> {
lastInSection = willWantDateSeparator ||
mxEv.getSender() !== nextEv.getSender() ||
getEventDisplayInfo(nextEv).isInfoMessage ||
!shouldFormContinuation(mxEv, nextEv, this.showHiddenEvents, this.context.timelineRenderingType);
!shouldFormContinuation(
mxEv, nextEv, this.showHiddenEvents, this.threadsEnabled, this.context.timelineRenderingType,
);
}
// is this a continuation of the previous message?
const continuation = !wantsDateSeparator &&
shouldFormContinuation(prevEvent, mxEv, this.showHiddenEvents, this.context.timelineRenderingType);
shouldFormContinuation(
prevEvent, mxEv, this.showHiddenEvents, this.threadsEnabled, this.context.timelineRenderingType,
);
const eventId = mxEv.getId();
const highlight = (eventId === this.props.highlightedEventId);