Improve uptime

This commit is contained in:
世界
2025-12-27 14:32:18 +08:00
parent 265902a011
commit 60ce084862

View File

@@ -445,9 +445,7 @@ class DashboardViewModel : BaseViewModel<DashboardUiState, UiEvent>(), CommandCl
checkDeprecatedNotes() checkDeprecatedNotes()
commandClient.connect() commandClient.connect()
reloadSystemProxyStatus() reloadSystemProxyStatus()
updateState { reloadStartedAt()
copy(serviceStartTime = System.currentTimeMillis())
}
} }
Status.Stopped -> { Status.Stopped -> {
@@ -478,6 +476,20 @@ class DashboardViewModel : BaseViewModel<DashboardUiState, UiEvent>(), CommandCl
} }
} }
private fun reloadStartedAt() {
viewModelScope.launch(Dispatchers.IO) {
try {
val startedAt = Libbox.newStandaloneCommandClient().startedAt
withContext(Dispatchers.Main) {
updateState {
copy(serviceStartTime = startedAt)
}
}
} catch (_: Exception) {
}
}
}
private fun reloadSystemProxyStatus() { private fun reloadSystemProxyStatus() {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
try { try {