Fix clear logs not working when service is stopped

This commit is contained in:
世界
2026-07-06 21:14:52 +08:00
parent aa686b2f1a
commit 78c5527a3d
@@ -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()
}
}
}