From 427b4406eaa7d12ddd9dd8e0c0a9be2f3fcb9cd0 Mon Sep 17 00:00:00 2001 From: Florian Duros <florian.duros@ormaz.fr> Date: Fri, 6 Sep 2024 16:12:10 +0200 Subject: [PATCH] Fix timeline link to same event --- src/components/structures/TimelinePanel.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index 976c00e2fd..2cb2b3a4ee 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -271,6 +271,13 @@ class TimelinePanel extends React.Component<IProps, IState> { private callEventGroupers = new Map<string, LegacyCallEventGrouper>(); private initialReadMarkerId: string | null = null; + /** + * True when the user has scrolled + * Reset to false after a call of `loadTimeline` + * @private + */ + private scrolled = false; + public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) { super(props, context); @@ -368,6 +375,9 @@ class TimelinePanel extends React.Component<IProps, IState> { } else if (differentOverlayTimeline) { logger.log(`TimelinePanel updating overlay timeline.`); this.initTimeline(this.props); + } else if (this.props.eventScrollIntoView && this.scrolled) { + // If the user has scrolled, and we want to display again the same event + this.initTimeline(this.props); } } @@ -659,6 +669,8 @@ class TimelinePanel extends React.Component<IProps, IState> { private onMessageListScroll = (e: Event): void => { this.props.onScroll?.(e); + this.scrolled = true; + if (this.props.manageReadMarkers) { this.doManageReadMarkers(); } @@ -1560,6 +1572,7 @@ class TimelinePanel extends React.Component<IProps, IState> { // We need to skip over any which have subsequently been sent. this.advanceReadMarkerPastMyEvents(); + this.scrolled = false; this.setState( { canBackPaginate: -- GitLab