Skip to content

Commit

Permalink
Fix timeline property
Browse files Browse the repository at this point in the history
the `timeline` property was always undefined, and the getter that existed on the thread object was some reason not applied...
  • Loading branch information
germain-gg committed Dec 2, 2022
1 parent f79e055 commit 52318e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
Array.from(this.threads)
.forEach(([, thread]) => {
if (thread.length === 0) return;
const currentUserParticipated = thread.events.some(event => {
const currentUserParticipated = thread.timeline.some(event => {
return event.getSender() === this.client.getUserId();
});
if (filterType !== ThreadFilterType.My || currentUserParticipated) {
Expand Down
13 changes: 6 additions & 7 deletions src/models/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
* A reference to all the events ID at the bottom of the threads
*/
public readonly timelineSet: EventTimelineSet;
public timeline: MatrixEvent[] = [];

private _currentUserParticipated = false;

Expand Down Expand Up @@ -181,7 +182,7 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
private onRedaction = async (event: MatrixEvent): Promise<void> => {
if (event.threadRootId !== this.id) return; // ignore redactions for other timelines
if (this.replyCount <= 0) {
for (const threadEvent of this.events) {
for (const threadEvent of this.timeline) {
this.clearEventMetadata(threadEvent);
}
this.lastEvent = this.rootEvent;
Expand Down Expand Up @@ -228,6 +229,7 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
roomState: this.roomState,
},
);
this.timeline = this.events;
}
}

Expand Down Expand Up @@ -287,6 +289,7 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
this.setEventMetadata(event);
await this.fetchEditsWhereNeeded(event);
}
this.timeline = this.events;
}

private getRootEventBundledRelationship(rootEvent = this.rootEvent): IThreadBundledRelationship | undefined {
Expand Down Expand Up @@ -374,8 +377,8 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
* Return last reply to the thread, if known.
*/
public lastReply(matches: (ev: MatrixEvent) => boolean = (): boolean => true): MatrixEvent | null {
for (let i = this.events.length - 1; i >= 0; i--) {
const event = this.events[i];
for (let i = this.timeline.length - 1; i >= 0; i--) {
const event = this.timeline[i];
if (matches(event)) {
return event;
}
Expand Down Expand Up @@ -423,10 +426,6 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
return this.timelineSet;
}

public get timeline(): MatrixEvent[] {
return this.events;
}

public addReceipt(event: MatrixEvent, synthetic: boolean): void {
throw new Error("Unsupported function on the thread model");
}
Expand Down

0 comments on commit 52318e1

Please sign in to comment.