Fix clear logs not working when service is stopped
This commit is contained in:
@@ -98,10 +98,16 @@ class LogViewModel :
|
|||||||
|
|
||||||
override fun requestClearLogs() {
|
override fun requestClearLogs() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
withContext(Dispatchers.IO) {
|
val sent =
|
||||||
runCatching {
|
withContext(Dispatchers.IO) {
|
||||||
Libbox.newStandaloneCommandClient().clearLogs()
|
runCatching {
|
||||||
|
Libbox.newStandaloneCommandClient().clearLogs()
|
||||||
|
}.isSuccess
|
||||||
}
|
}
|
||||||
|
// With the service stopped there is no broadcast to clear the UI,
|
||||||
|
// so the local buffer is cleared directly.
|
||||||
|
if (!sent) {
|
||||||
|
clearLogs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user