Use updates stable relations from js-sdk (#8715)

* Use updates stable relations from js-sdk

* Relations is now accessible on the Room instead

* Reuse more existing code and ditch confusing `isThreadRelation`

* Fix last usage of removed `isThreadRelation`

* Update tests to match removal of isThreadRelation

* Tweak method naming to closer match spec

* Fix missing method name change
This commit is contained in:
Michael Telatynski 2022-06-07 11:16:54 +01:00 committed by GitHub
parent 56b0b79fb7
commit 21d0aaf524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 54 deletions

View file

@ -1425,27 +1425,18 @@ class TimelinePanel extends React.Component<IProps, IState> {
// if we're at the end of the live timeline, append the pending events
if (!this.timelineWindow.canPaginate(EventTimeline.FORWARDS)) {
const pendingEvents = this.props.timelineSet.getPendingEvents();
if (this.context.timelineRenderingType === TimelineRenderingType.Thread) {
events.push(...pendingEvents.filter(e => e.threadRootId === this.context.threadId));
} else {
events.push(...pendingEvents.filter(e => {
const hasNoRelation = !e.getRelation();
if (hasNoRelation) {
return true;
}
events.push(...pendingEvents.filter(event => {
const {
shouldLiveInRoom,
threadId,
} = this.props.timelineSet.room.eventShouldLiveIn(event, pendingEvents);
if (e.isThreadRelation) {
return false;
}
const parentEvent = this.props.timelineSet.findEventById(e.getAssociatedId());
if (!parentEvent) {
return false;
} else {
return !parentEvent.isThreadRelation;
}
}));
}
if (this.context.timelineRenderingType === TimelineRenderingType.Thread) {
return threadId === this.context.threadId;
} {
return shouldLiveInRoom;
}
}));
}
return {
@ -1678,7 +1669,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
eventId: string,
relationType: RelationType,
eventType: EventType | string,
) => this.props.timelineSet.getRelationsForEvent(eventId, relationType, eventType);
) => this.props.timelineSet.relations?.getChildEventsForEvent(eventId, relationType, eventType);
private buildCallEventGroupers(events?: MatrixEvent[]): void {
this.callEventGroupers = buildCallEventGroupers(this.callEventGroupers, events);