Fix race conditions around threads (#8448)

This commit is contained in:
Michael Telatynski 2022-05-03 14:25:08 +01:00 committed by GitHub
parent 1aaaad2f32
commit f29ef04751
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 67 deletions

View file

@ -499,16 +499,18 @@ export class UnwrappedEventTile extends React.Component<IProps, IState> {
return null;
}
let thread = this.props.mxEvent.getThread();
/**
* Accessing the threads value through the room due to a race condition
* that will be solved when there are proper backend support for threads
* We currently have no reliable way to discover than an event is a thread
* when we are at the sync stage
*/
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
const thread = room?.threads?.get(this.props.mxEvent.getId());
return thread || null;
if (!thread) {
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
thread = room?.findThreadForEvent(this.props.mxEvent);
}
return thread ?? null;
}
private renderThreadPanelSummary(): JSX.Element | null {