1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-12-20 20:42:03 +03:00

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

This commit is contained in:
Germain
2022-10-27 13:50:05 +01:00
committed by GitHub
parent af47b74992
commit 07003a5bc1
2 changed files with 63 additions and 2 deletions

View File

@@ -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) {
@@ -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();
});
return Math.max(mainTimelineLastTs, ...threadLastEventTimestamps);
};
/**