refactor: extract NodeMenu from UsersFragment

This commit is contained in:
andrekir 2024-06-23 08:36:40 -03:00
parent db500c5200
commit f75879603e
3 changed files with 99 additions and 57 deletions

View file

@ -265,6 +265,7 @@ class UIViewModel @Inject constructor(
}
fun requestTraceroute(destNum: Int) {
info("Requesting traceroute for '$destNum'")
try {
val packetId = meshService?.packetId ?: return
meshService?.requestTraceroute(packetId, destNum)
@ -274,16 +275,18 @@ class UIViewModel @Inject constructor(
}
fun removeNode(nodeNum: Int) = viewModelScope.launch(Dispatchers.IO) {
info("Removing node '$nodeNum'")
try {
val packetId = meshService?.packetId ?: return@launch
meshService?.removeByNodenum(packetId, nodeNum)
nodeDB.deleteNode(nodeNum)
} catch (ex: RemoteException) {
errormsg("Request traceroute error: ${ex.message}")
errormsg("Remove node error: ${ex.message}")
}
}
fun requestPosition(destNum: Int, position: Position = Position(0.0, 0.0, 0)) {
info("Requesting position for '$destNum'")
try {
meshService?.requestPosition(destNum, position)
} catch (ex: RemoteException) {