From 79c1384ea796e92da1041191085ac57ecef1840b Mon Sep 17 00:00:00 2001 From: AndroidBob Date: Mon, 11 Mar 2024 13:50:07 +0100 Subject: [PATCH] fix: persistent ws not reflected in UI (WPB-7020) (#2771) Co-authored-by: Yamil Medina --- .../networkSettings/NetworkSettingsScreen.kt | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/settings/appsettings/networkSettings/NetworkSettingsScreen.kt b/app/src/main/kotlin/com/wire/android/ui/home/settings/appsettings/networkSettings/NetworkSettingsScreen.kt index 312e5b3f722..a25fb847f99 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/settings/appsettings/networkSettings/NetworkSettingsScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/settings/appsettings/networkSettings/NetworkSettingsScreen.kt @@ -21,7 +21,6 @@ package com.wire.android.ui.home.settings.appsettings.networkSettings import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import com.wire.android.ui.common.scaffold.WireScaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -33,6 +32,7 @@ import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.RootNavGraph import com.wire.android.R import com.wire.android.navigation.Navigator +import com.wire.android.ui.common.scaffold.WireScaffold import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar import com.wire.android.ui.home.conversations.details.options.ArrowType import com.wire.android.ui.home.conversations.details.options.GroupConversationOptionsItem @@ -74,20 +74,27 @@ fun NetworkSettingsScreenContent( .fillMaxSize() .padding(internalPadding) ) { - if (!isWebsocketEnabledByDefault(LocalContext.current)) { - GroupConversationOptionsItem( - title = stringResource(R.string.settings_keep_connection_to_websocket), - subtitle = stringResource( - R.string.settings_keep_connection_to_websocket_description, - backendName - ), - switchState = SwitchState.Enabled( - value = isWebSocketEnabled, - onCheckedChange = setWebSocketState - ), - arrowType = ArrowType.NONE + val appContext = LocalContext.current + val isWebSocketEnforcedByDefault = isWebsocketEnabledByDefault(appContext) + + val switchState = if (isWebSocketEnforcedByDefault) { + SwitchState.TextOnly(true) + } else { + SwitchState.Enabled( + value = isWebSocketEnabled, + onCheckedChange = setWebSocketState ) } + + GroupConversationOptionsItem( + title = stringResource(R.string.settings_keep_connection_to_websocket), + subtitle = stringResource( + R.string.settings_keep_connection_to_websocket_description, + backendName + ), + switchState = switchState, + arrowType = ArrowType.NONE + ) } } }