sort bug in the event that your pubkey is the 2nd item in the list

This commit is contained in:
Liran Cohen 2023-01-25 09:44:12 -05:00
parent d2751f8a4a
commit 61c88d654c
No known key found for this signature in database
GPG Key ID: 948C15655A7915C5

View File

@ -57,8 +57,9 @@ export default function MessagesPage() {
<div className="btn" onClick={() => markAllRead()}>Mark All Read</div>
</div>
{chats.sort((a, b) => {
if(b.pubkey === myPubKey) return 1
return b.newestMessage - a.newestMessage
return a.pubkey === myPubKey ? -1 :
b.pubkey === myPubKey ? 1 :
b.newestMessage - a.newestMessage
}).map(person)}
</>
)