fix: Verbindungs-Noise unterdrücken
- loadSettings() ruft connect() nur noch auf wenn ConnectionState NotConfigured oder Disconnected ist – verhindert den self-triggering Loop (pullSync → loadSettings → connect → Connecting → Connected → …) - pullSync() erhält Parameter silent=true für den initialen Connect-Sync; zeigt kein 'Empfange Inventar-Update…' mehr beim bloßen Verbindungsaufbau - Version 1.2 (3) → 1.3 (4)
This commit is contained in:
parent
152f484d4f
commit
aafb9ddd64
2 changed files with 11 additions and 6 deletions
|
|
@ -15,8 +15,8 @@ android {
|
||||||
applicationId = "de.bollwerk.app"
|
applicationId = "de.bollwerk.app"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 3
|
versionCode = 4
|
||||||
versionName = "1.2"
|
versionName = "1.3"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
buildConfigField("boolean", "FEATURE_CAMERA_ENABLED", "true")
|
buildConfigField("boolean", "FEATURE_CAMERA_ENABLED", "true")
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ internal class SettingsViewModel @Inject constructor(
|
||||||
showActivity(SyncActivityMessage.Error(event.message))
|
showActivity(SyncActivityMessage.Error(event.message))
|
||||||
}
|
}
|
||||||
is WebSocketEvent.Connected -> {
|
is WebSocketEvent.Connected -> {
|
||||||
pullSync(fullSync = false)
|
pullSync(fullSync = false, silent = true)
|
||||||
}
|
}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +134,12 @@ internal class SettingsViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
webSocketClient.connect(serverUrl, accessToken)
|
val currentState = webSocketClient.connectionState.value
|
||||||
|
if (currentState == ConnectionState.NotConfigured
|
||||||
|
|| currentState is ConnectionState.Disconnected
|
||||||
|
) {
|
||||||
|
webSocketClient.connect(serverUrl, accessToken)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
|
|
@ -427,10 +432,10 @@ internal class SettingsViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pullSync(fullSync: Boolean = false) {
|
fun pullSync(fullSync: Boolean = false, silent: Boolean = false) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
_uiState.update { it.copy(isSyncing = true) }
|
_uiState.update { it.copy(isSyncing = true) }
|
||||||
showActivity(SyncActivityMessage.ReceivingUpdate)
|
if (!silent) showActivity(SyncActivityMessage.ReceivingUpdate)
|
||||||
try {
|
try {
|
||||||
val since = if (fullSync) null else settingsRepository.getStringOrNull(StringKey.SyncLastTimestamp)?.toLongOrNull()
|
val since = if (fullSync) null else settingsRepository.getStringOrNull(StringKey.SyncLastTimestamp)?.toLongOrNull()
|
||||||
val result = syncService.downloadInventory(since)
|
val result = syncService.downloadInventory(since)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue