refactor: sort node list by lastHeard in database query

This commit is contained in:
andrekir 2024-03-31 16:45:07 -03:00
parent ff36b21298
commit cb7ef639c0
2 changed files with 1 additions and 5 deletions

View file

@ -25,7 +25,7 @@ interface NodeInfoDao {
@Query("SELECT * FROM NodeInfo")
fun getNodes(): Flow<List<NodeInfo>>
@Query("SELECT * FROM NodeInfo ORDER BY CASE WHEN num = (SELECT myNodeNum FROM MyNodeInfo LIMIT 1) THEN 0 ELSE 1 END, num ASC")
@Query("SELECT * FROM NodeInfo ORDER BY CASE WHEN num = (SELECT myNodeNum FROM MyNodeInfo LIMIT 1) THEN 0 ELSE 1 END, lastHeard DESC")
fun nodeDBbyNum(): Flow<Map<@MapColumn(columnName = "num") Int, NodeInfo>>
@Query("SELECT * FROM NodeInfo")

View file

@ -222,10 +222,6 @@ class UsersFragment : ScreenFragment("Users"), Logging {
return
}
if (nodesIn.size > 1) {
nodesIn.sortWith(compareByDescending { it.lastHeard }, 1)
}
val previousNodes = nodes
if (nodesIn.size < previousNodes.size) {