Merge pull request #6772 from matrix-org/gsouquet/fix-18947

pull/21833/head
Germain 2021-09-09 18:56:49 +01:00 committed by GitHub
commit 051e166c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -52,6 +52,7 @@ interface IState {
@replaceableComponent("structures.ThreadView") @replaceableComponent("structures.ThreadView")
export default class ThreadView extends React.Component<IProps, IState> { export default class ThreadView extends React.Component<IProps, IState> {
private dispatcherRef: string; private dispatcherRef: string;
private timelinePanelRef: React.RefObject<TimelinePanel> = React.createRef();
constructor(props: IProps) { constructor(props: IProps) {
super(props); super(props);
@ -112,10 +113,13 @@ export default class ThreadView extends React.Component<IProps, IState> {
private updateThread = (thread?: Thread) => { private updateThread = (thread?: Thread) => {
if (thread) { if (thread) {
this.setState({ thread }); this.setState({
} else { thread,
this.forceUpdate(); replyToEvent: thread.replyToEvent,
});
} }
this.timelinePanelRef.current?.refreshTimeline();
}; };
public render(): JSX.Element { public render(): JSX.Element {
@ -128,6 +132,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
> >
{ this.state.thread && ( { this.state.thread && (
<TimelinePanel <TimelinePanel
ref={this.timelinePanelRef}
manageReadReceipts={false} manageReadReceipts={false}
manageReadMarkers={false} manageReadMarkers={false}
timelineSet={this.state?.thread?.timelineSet} timelineSet={this.state?.thread?.timelineSet}

View File

@ -1195,6 +1195,12 @@ class TimelinePanel extends React.Component<IProps, IState> {
this.setState(this.getEvents()); this.setState(this.getEvents());
} }
// Force refresh the timeline before threads support pending events
public refreshTimeline(): void {
this.loadTimeline();
this.reloadEvents();
}
// get the list of events from the timeline window and the pending event list // get the list of events from the timeline window and the pending event list
private getEvents(): Pick<IState, "events" | "liveEvents" | "firstVisibleEventIndex"> { private getEvents(): Pick<IState, "events" | "liveEvents" | "firstVisibleEventIndex"> {
const events: MatrixEvent[] = this.timelineWindow.getEvents(); const events: MatrixEvent[] = this.timelineWindow.getEvents();