Prioritize named users in geohash peer list sorting

This commit is contained in:
a1denvalu3 2026-01-18 23:25:29 +01:00
parent b30ab84722
commit c1752844ee

View File

@ -108,13 +108,24 @@ fun GeohashPeopleList(
}
}
// Sort people: me first, then by lastSeen (matches iOS exactly)
// Sort people: me first, then named users, then anons (by lastSeen within groups)
val orderedPeople = remember(geohashPeople, myHex) {
geohashPeople.sortedWith { a, b ->
// Check if display name indicates an "anon" (shortened hex)
val aIsAnon = a.displayName == "${a.id.take(8)}..."
val bIsAnon = b.displayName == "${b.id.take(8)}..."
when {
// 1. Me always first
myHex != null && a.id == myHex && b.id != myHex -> -1
myHex != null && b.id == myHex && a.id != myHex -> 1
else -> b.lastSeen.compareTo(a.lastSeen) // Most recent first
// 2. Named users before anon users
!aIsAnon && bIsAnon -> -1
aIsAnon && !bIsAnon -> 1
// 3. Otherwise sort by recency
else -> b.lastSeen.compareTo(a.lastSeen)
}
}
}