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

Move updated threads to the end of the thread list #2923

Merged
merged 3 commits into from
Dec 2, 2022
Merged
Changes from 1 commit
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
14 changes: 9 additions & 5 deletions src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
}

private onThreadNewReply(thread: Thread): void {
this.updateThreadRootEvents(thread, false);
this.updateThreadRootEvents(thread, false, true);
}

private onThreadDelete(thread: Thread): void {
Expand Down Expand Up @@ -1968,11 +1968,11 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
));
}

private updateThreadRootEvents = (thread: Thread, toStartOfTimeline: boolean): void => {
private updateThreadRootEvents = (thread: Thread, toStartOfTimeline: boolean, recreateEvent: boolean): void => {
richvdh marked this conversation as resolved.
Show resolved Hide resolved
if (thread.length) {
this.updateThreadRootEvent(this.threadsTimelineSets?.[0], thread, toStartOfTimeline);
this.updateThreadRootEvent(this.threadsTimelineSets?.[0], thread, toStartOfTimeline, recreateEvent);
if (thread.hasCurrentUserParticipated) {
this.updateThreadRootEvent(this.threadsTimelineSets?.[1], thread, toStartOfTimeline);
this.updateThreadRootEvent(this.threadsTimelineSets?.[1], thread, toStartOfTimeline, recreateEvent);
}
}
};
Expand All @@ -1981,8 +1981,12 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
timelineSet: Optional<EventTimelineSet>,
thread: Thread,
toStartOfTimeline: boolean,
recreateEvent: boolean,
): void => {
if (timelineSet && thread.rootEvent) {
if (recreateEvent) {
timelineSet.removeEvent(thread.id);
}
justjanne marked this conversation as resolved.
Show resolved Hide resolved
if (Thread.hasServerSideSupport) {
timelineSet.addLiveEvent(thread.rootEvent, {
duplicateStrategy: DuplicateStrategy.Replace,
Expand Down Expand Up @@ -2045,7 +2049,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
}

if (this.threadsReady) {
this.updateThreadRootEvents(thread, toStartOfTimeline);
this.updateThreadRootEvents(thread, toStartOfTimeline, false);
}

this.emit(ThreadEvent.New, thread, toStartOfTimeline);
Expand Down