Unread DMs are ALWAYS at the top. Closes #185.

This commit is contained in:
Jack Kingsman
2026-04-12 22:41:41 -07:00
parent eccbd0bac5
commit 33b2d3c260
2 changed files with 43 additions and 1 deletions
+7 -1
View File
@@ -265,6 +265,12 @@ export function Sidebar({
const sortContactsByOrder = useCallback(
(items: Contact[], order: SortOrder) =>
[...items].sort((a, b) => {
// Unread DM contacts always float to the top
const unreadA = unreadCounts[getStateKey('contact', a.public_key)] || 0;
const unreadB = unreadCounts[getStateKey('contact', b.public_key)] || 0;
if (unreadA > 0 && unreadB === 0) return -1;
if (unreadA === 0 && unreadB > 0) return 1;
if (order === 'recent') {
const timeA = getContactRecentTime(a);
const timeB = getContactRecentTime(b);
@@ -274,7 +280,7 @@ export function Sidebar({
}
return (a.name || a.public_key).localeCompare(b.name || b.public_key);
}),
[getContactRecentTime]
[getContactRecentTime, unreadCounts]
);
const sortRepeatersByOrder = useCallback(