Skip to content

Commit d6883d5

Browse files
committed
Only set recurse parameter if supported
1 parent 8b72910 commit d6883d5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/client.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5736,6 +5736,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
57365736
return undefined;
57375737
}
57385738

5739+
const recurse = this.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
57395740
if (Thread.hasServerSideSupport) {
57405741
if (Thread.hasServerSideFwdPaginationSupport) {
57415742
if (!timelineSet.thread) {
@@ -5748,14 +5749,14 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
57485749
thread.id,
57495750
THREAD_RELATION_TYPE.name,
57505751
null,
5751-
{ dir: Direction.Backward, from: res.start, recurse: true },
5752+
{ dir: Direction.Backward, from: res.start, recurse: recurse || undefined },
57525753
);
57535754
const resNewer: IRelationsResponse = await this.fetchRelations(
57545755
timelineSet.room.roomId,
57555756
thread.id,
57565757
THREAD_RELATION_TYPE.name,
57575758
null,
5758-
{ dir: Direction.Forward, from: res.end, recurse: true },
5759+
{ dir: Direction.Forward, from: res.end, recurse: recurse || undefined },
57595760
);
57605761
const events = [
57615762
// Order events from most recent to oldest (reverse-chronological).
@@ -5803,7 +5804,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
58035804
thread.id,
58045805
THREAD_RELATION_TYPE.name,
58055806
null,
5806-
{ dir: Direction.Backward, from: res.start, recurse: true },
5807+
{ dir: Direction.Backward, from: res.start, recurse: recurse || undefined },
58075808
);
58085809
const eventsNewer: IEvent[] = [];
58095810
let nextBatch: Optional<string> = res.end;
@@ -5813,7 +5814,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
58135814
thread.id,
58145815
THREAD_RELATION_TYPE.name,
58155816
null,
5816-
{ dir: Direction.Forward, from: nextBatch, recurse: true },
5817+
{ dir: Direction.Forward, from: nextBatch, recurse: recurse || undefined },
58175818
);
58185819
nextBatch = resNewer.next_batch ?? null;
58195820
eventsNewer.push(...resNewer.chunk);
@@ -5884,12 +5885,13 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
58845885
);
58855886
event = res.chunk?.[0];
58865887
} else if (timelineSet.thread && Thread.hasServerSideSupport) {
5888+
const recurse = this.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
58875889
const res = await this.fetchRelations(
58885890
timelineSet.room.roomId,
58895891
timelineSet.thread.id,
58905892
THREAD_RELATION_TYPE.name,
58915893
null,
5892-
{ dir: Direction.Backward, limit: 1, recurse: true },
5894+
{ dir: Direction.Backward, limit: 1, recurse: recurse || undefined },
58935895
);
58945896
event = res.chunk?.[0];
58955897
} else {
@@ -6164,11 +6166,12 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
61646166
throw new Error("Unknown room " + eventTimeline.getRoomId());
61656167
}
61666168

6169+
const recurse = this.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
61676170
promise = this.fetchRelations(eventTimeline.getRoomId() ?? "", thread.id, THREAD_RELATION_TYPE.name, null, {
61686171
dir,
61696172
limit: opts.limit,
61706173
from: token ?? undefined,
6171-
recurse: true,
6174+
recurse: recurse || undefined,
61726175
})
61736176
.then(async (res) => {
61746177
const mapper = this.getEventMapper();

0 commit comments

Comments
 (0)