Fix clear logs not working when service is stopped
This commit is contained in:
@@ -98,10 +98,16 @@ class LogViewModel :
|
||||
|
||||
override fun requestClearLogs() {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
runCatching {
|
||||
Libbox.newStandaloneCommandClient().clearLogs()
|
||||
val sent =
|
||||
withContext(Dispatchers.IO) {
|
||||
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