v1.0.1: boton Reintentar en dashboard y carga automatica de URL guardada

This commit is contained in:
2026-08-04 13:25:06 -06:00
parent e55ce75c9b
commit f8631e9a63
3 changed files with 18 additions and 4 deletions
@@ -34,6 +34,7 @@ import com.conta.app.data.network.Session
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import java.io.File
@@ -82,6 +83,14 @@ class AppViewModel : ViewModel() {
_message.value = msg
}
init {
viewModelScope.launch {
val saved = ServiceLocator.settings.baseUrl.first()
Session.baseUrl = saved
if (saved.isNotBlank()) refreshAll()
}
}
private suspend fun <T> runRequest(block: suspend () -> T): Boolean {
return try {
block()
@@ -95,8 +95,13 @@ fun DashboardScreen(viewModel: AppViewModel, navController: NavController) {
verticalArrangement = Arrangement.Center,
) {
EmptyState("No conectado. Configura la URL del servidor en Ajustes.")
androidx.compose.material3.Button(onClick = { navController.navigate(Routes.SETTINGS) }) {
Text("Ir a Ajustes")
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
androidx.compose.material3.Button(onClick = { viewModel.refreshAll() }) {
Text("Reintentar")
}
androidx.compose.material3.OutlinedButton(onClick = { navController.navigate(Routes.SETTINGS) }) {
Text("Ir a Ajustes")
}
}
}
}