Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort contactlist so that offline friends with push urls are shown above other offline friends #197

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plot_mem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash
pp=$(jcmd|grep 'MainKt'|cut -d' ' -f1);while :; do grep -oP '^VmRSS:\s+\K\d+' /proc/$pp/status \
| numfmt --from-unit Ki --to-unit Mi; sleep 1; done | ttyplot -u Mi
16 changes: 14 additions & 2 deletions src/main/kotlin/com/zoffcc/applications/trifa/ContactStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,26 @@ fun CoroutineScope.createContactStore(): ContactStore
}
}

val friendsRolesOrder = mapOf(0 to 3, 1 to 1, 2 to 0)
val friendsRolesOrder = mapOf(0 to 3, 4 to 2, 1 to 1, 2 to 0)

fun getFriendListWithGroupingAndSorting(friendlist: ArrayList<ContactItem>)
: ArrayList<ContactItem>
{
return ArrayList(friendlist.sortedWith(
compareBy<ContactItem> { it.is_relay }.
thenBy<ContactItem> { friendsRolesOrder[it.isConnected] }.
thenBy<ContactItem> {
// HINT: sort by connection status
// if offline the also show contact with push_urls set above fully offline contacts
var tmp_sort_value = it.isConnected
if (tmp_sort_value == 0) {
if (!it.is_relay) {
if (!it.push_url.isNullOrEmpty()) {
tmp_sort_value = 4
}
}
}
friendsRolesOrder[tmp_sort_value]
}.
thenBy { it.name.toLowerCase() }
)
)
Expand Down
Loading