Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip processing thread roots and fetching threads list when support is disabled #3642

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/integ/matrix-client-event-timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function startClient(httpBackend: HttpBackend, client: MatrixClient) {
httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA);

client.startClient();
client.startClient({ threadSupport: true });

// set up a promise which will resolve once the client is initialised
const prom = new Promise<void>((resolve) => {
Expand Down
1 change: 1 addition & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9768,6 +9768,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @param toStartOfTimeline - the direction
*/
public processThreadRoots(room: Room, threadedEvents: MatrixEvent[], toStartOfTimeline: boolean): void {
if (!this.supportsThreads()) return;
room.processThreadRoots(threadedEvents, toStartOfTimeline);
}

Expand Down
2 changes: 2 additions & 0 deletions src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
* Takes the given thread root events and creates threads for them.
*/
public processThreadRoots(events: MatrixEvent[], toStartOfTimeline: boolean): void {
if (!this.client.supportsThreads()) return;
for (const rootEvent of events) {
EventTimeline.setEventMetadata(rootEvent, this.currentState, toStartOfTimeline);
if (!this.getThread(rootEvent.getId()!)) {
Expand Down Expand Up @@ -2031,6 +2032,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
* @internal
*/
private async fetchRoomThreadList(filter?: ThreadFilterType): Promise<void> {
if (!this.client.supportsThreads()) return;
if (this.threadsTimelineSets.length === 0) return;

const timelineSet = filter === ThreadFilterType.My ? this.threadsTimelineSets[1] : this.threadsTimelineSets[0];
Expand Down
Loading