diff --git a/app/src/main/java/io/nekohasekai/sfa/compose/screen/log/LogViewModel.kt b/app/src/main/java/io/nekohasekai/sfa/compose/screen/log/LogViewModel.kt index ecaf56d..ef7ebe1 100644 --- a/app/src/main/java/io/nekohasekai/sfa/compose/screen/log/LogViewModel.kt +++ b/app/src/main/java/io/nekohasekai/sfa/compose/screen/log/LogViewModel.kt @@ -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() } } }