diff --git a/app/src/main/java/io/nekohasekai/sfa/compose/screen/dashboard/DashboardViewModel.kt b/app/src/main/java/io/nekohasekai/sfa/compose/screen/dashboard/DashboardViewModel.kt index dc5d447..c9948c0 100644 --- a/app/src/main/java/io/nekohasekai/sfa/compose/screen/dashboard/DashboardViewModel.kt +++ b/app/src/main/java/io/nekohasekai/sfa/compose/screen/dashboard/DashboardViewModel.kt @@ -445,9 +445,7 @@ class DashboardViewModel : BaseViewModel(), CommandCl checkDeprecatedNotes() commandClient.connect() reloadSystemProxyStatus() - updateState { - copy(serviceStartTime = System.currentTimeMillis()) - } + reloadStartedAt() } Status.Stopped -> { @@ -478,6 +476,20 @@ class DashboardViewModel : BaseViewModel(), 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() { viewModelScope.launch(Dispatchers.IO) { try {