mirror of https://github.com/vector-im/riot-web
Force refresh threads timeline
Fixes vector-im/element-web#18947 In the absence of a proper pending events / remote echo setup it seems fairly difficult to get the timeline to update Adding a temporary helper to force refresh the timeline and not swallow local events when sending a message from the thread sidebarpull/21833/head
parent
8cf891f9a4
commit
672dab1998
|
@ -50,6 +50,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);
|
||||||
|
@ -110,10 +111,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 {
|
||||||
|
@ -126,6 +130,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}
|
||||||
|
|
|
@ -1179,6 +1179,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();
|
||||||
|
|
Loading…
Reference in New Issue