From f988de162cfd075463017d50b6d4f68de5b66a19 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Thu, 20 Oct 2022 17:38:30 +0200 Subject: [PATCH] Fix issue where thread list wasn't properly filtered --- src/client.ts | 20 +++++++++++++++----- src/models/event-timeline-set.ts | 4 ++-- src/models/room.ts | 7 ++++++- src/models/thread.ts | 9 +++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/client.ts b/src/client.ts index a9646ea6d1f..f333527b7da 100644 --- a/src/client.ts +++ b/src/client.ts @@ -189,7 +189,14 @@ import { TypedEventEmitter } from "./models/typed-event-emitter"; import { ReceiptType } from "./@types/read_receipts"; import { MSC3575SlidingSyncRequest, MSC3575SlidingSyncResponse, SlidingSync } from "./sliding-sync"; import { SlidingSyncSdk } from "./sliding-sync-sdk"; -import { FeatureSupport, Thread, THREAD_RELATION_TYPE, determineFeatureSupport } from "./models/thread"; +import { + FeatureSupport, + Thread, + THREAD_RELATION_TYPE, + determineFeatureSupport, + ThreadFilterType, + threadFilterTypeToFilter +} from "./models/thread"; import { MBeaconInfoEventContent, M_BEACON_INFO } from "./@types/beacon"; import { UnstableValue } from "./NamespacedValue"; import { ToDeviceMessageQueue } from "./ToDeviceMessageQueue"; @@ -5408,12 +5415,13 @@ export class MatrixClient extends TypedEventEmitter { const path = utils.encodeUri("/rooms/$roomId/threads", { $roomId: roomId }); @@ -5524,7 +5533,7 @@ export class MatrixClient extends TypedEventEmitter = { limit: limit.toString(), dir: dir, - include: 'all', + include: threadFilterTypeToFilter(threadListType), }; if (fromToken) { @@ -5583,7 +5592,7 @@ export class MatrixClient extends TypedEventEmitter { const isNotifTimeline = (eventTimeline.getTimelineSet() === this.notifTimelineSet); const room = this.getRoom(eventTimeline.getRoomId()); - const isThreadListTimeline = eventTimeline.getTimelineSet().isThreadTimeline; + const threadListType = eventTimeline.getTimelineSet().threadListType; const thread = eventTimeline.getTimelineSet().thread; // TODO: we should implement a backoff (as per scrollback()) to deal more @@ -5655,7 +5664,7 @@ export class MatrixClient extends TypedEventEmitter { if (res.state) { diff --git a/src/models/event-timeline-set.ts b/src/models/event-timeline-set.ts index 5ef710c37f0..df0fef7b5c7 100644 --- a/src/models/event-timeline-set.ts +++ b/src/models/event-timeline-set.ts @@ -27,7 +27,7 @@ import { RoomState } from "./room-state"; import { TypedEventEmitter } from "./typed-event-emitter"; import { RelationsContainer } from "./relations-container"; import { MatrixClient } from "../client"; -import { Thread } from "./thread"; +import { Thread, ThreadFilterType } from "./thread"; const DEBUG = true; @@ -140,7 +140,7 @@ export class EventTimelineSet extends TypedEventEmitter { private async createThreadTimelineSet(filterType?: ThreadFilterType): Promise { let timelineSet: EventTimelineSet; if (Thread.hasServerSideListSupport) { + let threadListType: ThreadFilterType | null = null; + if (Thread.hasServerSideListSupport) { + threadListType = filterType ?? ThreadFilterType.All; + } timelineSet = - new EventTimelineSet(this, this.opts, undefined, undefined, Boolean(Thread.hasServerSideListSupport)); + new EventTimelineSet(this, this.opts, undefined, undefined, threadListType); this.reEmitter.reEmit(timelineSet, [ RoomEvent.Timeline, RoomEvent.TimelineReset, @@ -1808,6 +1812,7 @@ export class Room extends ReadReceipt { null, undefined, Direction.Backward, + timelineSet.threadListType, timelineSet.getFilter(), ); diff --git a/src/models/thread.ts b/src/models/thread.ts index 19bf7415a07..4529970e669 100644 --- a/src/models/thread.ts +++ b/src/models/thread.ts @@ -435,3 +435,12 @@ export enum ThreadFilterType { "My", "All" } + +export function threadFilterTypeToFilter(type: ThreadFilterType): 'all' | 'participated' { + switch (type) { + case ThreadFilterType.My: + return 'participated'; + case ThreadFilterType.All: + return 'all'; + } +}