mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-06 16:53:38 +02:00
Unread DMs are ALWAYS at the top. Closes #185.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user