Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make thread replies trigger a room list re-ordering #9510

Merged
merged 4 commits into from
Oct 27, 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
10 changes: 8 additions & 2 deletions src/stores/room-list/algorithms/tag-sorting/RecentAlgorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const sortRooms = (rooms: Room[]): Room[] => {
};

const getLastTs = (r: Room, userId: string) => {
const ts = (() => {
const mainTimelineLastTs = (() => {
// Apparently we can have rooms without timelines, at least under testing
// environments. Just return MAX_INT when this happens.
if (!r?.timeline) {
Expand Down Expand Up @@ -108,7 +108,13 @@ const getLastTs = (r: Room, userId: string) => {
// This is better than just assuming the last event was forever ago.
return r.timeline[0]?.getTs() ?? Number.MAX_SAFE_INTEGER;
})();
return ts;

const threadLastEventTimestamps = r.getThreads().map(thread => {
const event = thread.replyToEvent ?? thread.rootEvent;
return event?.getTs() ?? 0;
});

return Math.max(mainTimelineLastTs, ...threadLastEventTimestamps);
};

/**
Expand Down