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
+2 -2
View File
@@ -13,8 +13,8 @@ android {
applicationId "com.conta.app" applicationId "com.conta.app"
minSdk 24 minSdk 24
targetSdk 34 targetSdk 34
versionCode 1 versionCode 2
versionName "1.0.0" versionName "1.0.1"
} }
buildTypes { buildTypes {
@@ -34,6 +34,7 @@ import com.conta.app.data.network.Session
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File import java.io.File
@@ -82,6 +83,14 @@ class AppViewModel : ViewModel() {
_message.value = msg _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 { private suspend fun <T> runRequest(block: suspend () -> T): Boolean {
return try { return try {
block() block()
@@ -95,11 +95,16 @@ fun DashboardScreen(viewModel: AppViewModel, navController: NavController) {
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
) { ) {
EmptyState("No conectado. Configura la URL del servidor en Ajustes.") EmptyState("No conectado. Configura la URL del servidor en Ajustes.")
androidx.compose.material3.Button(onClick = { navController.navigate(Routes.SETTINGS) }) { 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") Text("Ir a Ajustes")
} }
} }
} }
}
else -> DashboardContent( else -> DashboardContent(
summary = summary!!, summary = summary!!,
notices = notices, notices = notices,