From 4b682ad9305bea86df5356abce7f86d659ed1d2d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 27 Aug 2020 10:45:20 +0200 Subject: [PATCH] use the same check when seeing if either does not have a timestamp --- src/domain/session/roomlist/RoomTileViewModel.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/domain/session/roomlist/RoomTileViewModel.js b/src/domain/session/roomlist/RoomTileViewModel.js index 25ebf30e..5a73a86a 100644 --- a/src/domain/session/roomlist/RoomTileViewModel.js +++ b/src/domain/session/roomlist/RoomTileViewModel.js @@ -82,8 +82,10 @@ export class RoomTileViewModel extends ViewModel { } const myTimestamp = myRoom.lastMessageTimestamp; const theirTimestamp = theirRoom.lastMessageTimestamp; - // rooms with a timestamp come before rooms without one - if ((myTimestamp === null) !== (theirTimestamp === null)) { + const myTimestampValid = Number.isSafeInteger(myTimestamp); + const theirTimestampValid = Number.isSafeInteger(theirTimestamp); + // if either does not have a timestamp, put the one with a timestamp first + if (myTimestampValid !== theirTimestampValid) { log("checking if either does not have lastMessageTimestamp ..."); if (theirTimestamp === null) { return logResult(-1); @@ -91,7 +93,7 @@ export class RoomTileViewModel extends ViewModel { return logResult(1); } const timeDiff = theirTimestamp - myTimestamp; - if (timeDiff === 0 || !Number.isSafeInteger(theirTimestamp) || !Number.isSafeInteger(myTimestamp)) { + if (timeDiff === 0 || !theirTimestampValid || !myTimestampValid) { log("checking name ..."); // sort alphabetically const nameCmp = this.name.localeCompare(other.name);