diff --git a/spec/unit/filter-component.spec.ts b/spec/unit/filter-component.spec.ts index 636a413f6..1d029904c 100644 --- a/spec/unit/filter-component.spec.ts +++ b/spec/unit/filter-component.spec.ts @@ -126,7 +126,46 @@ describe("Filter Component", function() { event: true, }); + const eventWithMultipleRelations = mkEvent({ + "type": "m.room.message", + "content": {}, + "unsigned": { + "m.relations": { + "testtesttest": {}, + "m.annotation": { + "chunk": [ + { + "type": "m.reaction", + "key": "🤫", + "count": 1, + }, + ], + }, + [RelationType.Thread]: { + count: 2, + current_user_participated: true, + }, + }, + }, + "room": 'roomId', + "event": true, + }); + + const noMatchEvent = mkEvent({ + "type": "m.room.message", + "content": {}, + "unsigned": { + "m.relations": { + "testtesttest": {}, + }, + }, + "room": 'roomId', + "event": true, + }); + expect(filter.check(threadRootEvent)).toBe(true); + expect(filter.check(eventWithMultipleRelations)).toBe(true); + expect(filter.check(noMatchEvent)).toBe(false); }); }); }); diff --git a/src/client.ts b/src/client.ts index 18b9546df..0fa27f7b7 100644 --- a/src/client.ts +++ b/src/client.ts @@ -5383,7 +5383,7 @@ export class MatrixClient extends TypedEventEmitter 0 && values.every(value => { - return filter.includes(value); + return values.length > 0 && filter.every(value => { + return values.includes(value); }); } diff --git a/src/models/room.ts b/src/models/room.ts index aa649a9b1..36137c899 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -177,7 +177,7 @@ export type RoomEventHandlerMap = { oldEventId?: string, oldStatus?: EventStatus, ) => void; - [ThreadEvent.New]: (thread: Thread) => void; + [ThreadEvent.New]: (thread: Thread, toStartOfTimeline: boolean) => void; } & ThreadHandlerMap; export class Room extends TypedEventEmitter { @@ -1435,14 +1435,18 @@ export class Room extends TypedEventEmitter // it. If it wasn't fetched successfully the thread will work // in "limited" mode and won't benefit from all the APIs a homeserver // can provide to enhance the thread experience - thread = this.createThread(rootEvent, events); + thread = this.createThread(rootEvent, events, toStartOfTimeline); } } this.emit(ThreadEvent.Update, thread); } - public createThread(rootEvent: MatrixEvent | undefined, events: MatrixEvent[] = []): Thread | undefined { + public createThread( + rootEvent: MatrixEvent | undefined, + events: MatrixEvent[] = [], + toStartOfTimeline: boolean, + ): Thread | undefined { if (rootEvent) { const tl = this.getTimelineForEvent(rootEvent.getId()); const relatedEvents = tl?.getTimelineSet().getAllRelationsEventForEvent(rootEvent.getId()); @@ -1470,7 +1474,7 @@ export class Room extends TypedEventEmitter this.lastThread = thread; } - this.emit(ThreadEvent.New, thread); + this.emit(ThreadEvent.New, thread, toStartOfTimeline); return thread; } } diff --git a/src/timeline-window.ts b/src/timeline-window.ts index 4a38e23d7..936c910cf 100644 --- a/src/timeline-window.ts +++ b/src/timeline-window.ts @@ -240,7 +240,7 @@ export class TimelineWindow { } return Boolean(tl.timeline.getNeighbouringTimeline(direction) || - tl.timeline.getPaginationToken(direction)); + tl.timeline.getPaginationToken(direction) !== null); } /** @@ -297,7 +297,7 @@ export class TimelineWindow { // try making a pagination request const token = tl.timeline.getPaginationToken(direction); - if (!token) { + if (token === null) { debuglog("TimelineWindow: no token"); return Promise.resolve(false); }