mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: reindex node list when local node isn't first (index 0)
This commit is contained in:
parent
8151aceea4
commit
e2f63e015c
1 changed files with 9 additions and 1 deletions
|
|
@ -286,8 +286,16 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
binding.nodeListView.adapter = nodesAdapter
|
||||
binding.nodeListView.layoutManager = LinearLayoutManager(requireContext())
|
||||
|
||||
// ensure our local node is first (index 0)
|
||||
fun Map<String, NodeInfo>.perhapsReindexBy(nodeNum: Int?): Array<NodeInfo> =
|
||||
if (size > 1 && nodeNum != null && values.firstOrNull()?.num != nodeNum) {
|
||||
values.partition { node -> node.num == nodeNum }.let { it.first + it.second }
|
||||
} else {
|
||||
values
|
||||
}.toTypedArray()
|
||||
|
||||
model.nodeDB.nodes.observe(viewLifecycleOwner) {
|
||||
nodesAdapter.onNodesChanged(it.values.toTypedArray())
|
||||
nodesAdapter.onNodesChanged(it.perhapsReindexBy(model.myNodeNum))
|
||||
}
|
||||
|
||||
model.packetResponse.asLiveData().observe(viewLifecycleOwner) { meshLog ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue