refactor(core, veranstaltung): Exception-Handling vereinfacht und Delay-Angabe optimiert
Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
+3
-2
@@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.asStateFlow
|
|||||||
import org.koin.core.component.KoinComponent
|
import org.koin.core.component.KoinComponent
|
||||||
import org.koin.core.component.inject
|
import org.koin.core.component.inject
|
||||||
import org.koin.core.qualifier.named
|
import org.koin.core.qualifier.named
|
||||||
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Überwacht die Konnektivität zum API-Gateway.
|
* Überwacht die Konnektivität zum API-Gateway.
|
||||||
@@ -28,7 +29,7 @@ class ConnectivityTracker : KoinComponent {
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
_isOnline.value = checkConnection()
|
_isOnline.value = checkConnection()
|
||||||
delay(10_000) // Alle 10 Sekunden prüfen
|
delay(10_000.milliseconds) // Alle 10 Sekunden prüfen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +38,7 @@ class ConnectivityTracker : KoinComponent {
|
|||||||
return try {
|
return try {
|
||||||
val response = client.get(NetworkConfig.baseUrl.trimEnd('/') + "/api/ping/health")
|
val response = client.get(NetworkConfig.baseUrl.trimEnd('/') + "/api/ping/health")
|
||||||
response.status.value in 200..299
|
response.status.value in 200..299
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-9
@@ -29,6 +29,7 @@ import java.time.ZoneId
|
|||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import javax.swing.JFileChooser
|
import javax.swing.JFileChooser
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter
|
import javax.swing.filechooser.FileNameExtensionFilter
|
||||||
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -541,12 +542,12 @@ fun VeranstaltungKonfigV2(
|
|||||||
|
|
||||||
val dateVon = try {
|
val dateVon = try {
|
||||||
LocalDate.parse(von, dateFormatter)
|
LocalDate.parse(von, dateFormatter)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
val dateBis = try {
|
val dateBis = try {
|
||||||
LocalDate.parse(bis, dateFormatter)
|
LocalDate.parse(bis, dateFormatter)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
val today = LocalDate.now()
|
val today = LocalDate.now()
|
||||||
@@ -728,12 +729,12 @@ fun VeranstaltungKonfigV2(
|
|||||||
2 -> {
|
2 -> {
|
||||||
val dVon = try {
|
val dVon = try {
|
||||||
LocalDate.parse(von, dateFormatter)
|
LocalDate.parse(von, dateFormatter)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
val dBis = try {
|
val dBis = try {
|
||||||
LocalDate.parse(bis, dateFormatter)
|
LocalDate.parse(bis, dateFormatter)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
val today2 = LocalDate.now()
|
val today2 = LocalDate.now()
|
||||||
@@ -1086,12 +1087,12 @@ fun TurnierWizardV2(
|
|||||||
val vBis = veranstaltung?.datumBis?.let { LocalDate.parse(it) }
|
val vBis = veranstaltung?.datumBis?.let { LocalDate.parse(it) }
|
||||||
val tVon = try {
|
val tVon = try {
|
||||||
LocalDate.parse(von)
|
LocalDate.parse(von)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
val tBis = if (bis.isBlank()) tVon else try {
|
val tBis = if (bis.isBlank()) tVon else try {
|
||||||
LocalDate.parse(bis)
|
LocalDate.parse(bis)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1268,7 @@ private fun Step1Basics(
|
|||||||
CircularProgressIndicator()
|
CircularProgressIndicator()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
kotlinx.coroutines.delay(2000)
|
kotlinx.coroutines.delay(2000.milliseconds)
|
||||||
onZnsDataLoadedChange(true)
|
onZnsDataLoadedChange(true)
|
||||||
showImportProgress = false
|
showImportProgress = false
|
||||||
}
|
}
|
||||||
@@ -1295,12 +1296,12 @@ private fun Step2Sparten(
|
|||||||
val vBis = veranstaltung?.datumBis?.let { LocalDate.parse(it) }
|
val vBis = veranstaltung?.datumBis?.let { LocalDate.parse(it) }
|
||||||
val tVon = try {
|
val tVon = try {
|
||||||
LocalDate.parse(von)
|
LocalDate.parse(von)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
val tBis = if (bis.isBlank()) tVon else try {
|
val tBis = if (bis.isBlank()) tVon else try {
|
||||||
LocalDate.parse(bis)
|
LocalDate.parse(bis)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user