Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

View message in timeline doesn't work if requested twice #12968

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/components/structures/TimelinePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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:
Expand Down
Loading