Sort left pane via receivedAt/receivedAtMs, even via edits
This commit is contained in:
parent
a39e46db5c
commit
6bc6cc64c4
7 changed files with 55 additions and 11 deletions
|
@ -282,6 +282,8 @@ export type ConversationType = ReadonlyDeep<
|
|||
isVerified?: boolean;
|
||||
activeAt?: number;
|
||||
timestamp?: number;
|
||||
lastMessageReceivedAt?: number;
|
||||
lastMessageReceivedAtMs?: number;
|
||||
inboxPosition?: number;
|
||||
left?: boolean;
|
||||
lastMessage?: LastMessageType;
|
||||
|
|
|
@ -303,8 +303,9 @@ const collator = new Intl.Collator();
|
|||
// phone numbers and contacts from scratch here again.
|
||||
export const _getConversationComparator = () => {
|
||||
return (left: ConversationType, right: ConversationType): number => {
|
||||
const leftTimestamp = left.timestamp;
|
||||
const rightTimestamp = right.timestamp;
|
||||
// These two fields can be sorted with each other; they are timestamps
|
||||
const leftTimestamp = left.lastMessageReceivedAtMs || left.timestamp;
|
||||
const rightTimestamp = right.lastMessageReceivedAtMs || right.timestamp;
|
||||
if (leftTimestamp && !rightTimestamp) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -315,6 +316,19 @@ export const _getConversationComparator = () => {
|
|||
return rightTimestamp - leftTimestamp;
|
||||
}
|
||||
|
||||
// This field looks like a timestamp, but is actually a counter
|
||||
const leftCounter = left.lastMessageReceivedAt;
|
||||
const rightCounter = right.lastMessageReceivedAt;
|
||||
if (leftCounter && !rightCounter) {
|
||||
return -1;
|
||||
}
|
||||
if (rightCounter && !leftCounter) {
|
||||
return 1;
|
||||
}
|
||||
if (leftCounter && rightCounter && leftCounter !== rightCounter) {
|
||||
return rightCounter - leftCounter;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof left.inboxPosition === 'number' &&
|
||||
typeof right.inboxPosition === 'number'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue