Skip to content

Commit

Permalink
fix: change the connectivity message (RC) (#2102)
Browse files Browse the repository at this point in the history
Co-authored-by: Mateusz <m.pachulski94@gmail.com>
  • Loading branch information
ohassine and trOnk12 committed Aug 15, 2023
1 parent a6a1f6a commit 58341a1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -105,7 +105,8 @@ private fun ConnectivityStatusBar(
.animateContentSize()
.fillMaxWidth()
.height(MaterialTheme.wireDimensions.ongoingCallLabelHeight)
.background(backgroundColor).run {
.background(backgroundColor)
.run {
if (connectivityInfo is ConnectivityUIState.Info.EstablishedCall) {
clickable(onClick = onReturnToCallClick)
} else this
Expand All @@ -121,24 +122,18 @@ private fun ConnectivityStatusBar(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
if (connectivityInfo is ConnectivityUIState.Info.EstablishedCall) {
OngoingCallContent(connectivityInfo.isMuted)
} else {
val isConnecting = connectivityInfo is ConnectivityUIState.Info.Connecting
ConnectivityIssueContent(isConnecting)
when (connectivityInfo) {
is ConnectivityUIState.Info.EstablishedCall -> OngoingCallContent(connectivityInfo.isMuted)
ConnectivityUIState.Info.Connecting -> StatusLabel(R.string.connectivity_status_bar_connecting)
ConnectivityUIState.Info.WaitingConnection ->
StatusLabel(R.string.connectivity_status_bar_waiting_for_network)

ConnectivityUIState.Info.None -> {}
}
}
}
}

@Composable
private fun ConnectivityIssueContent(isConnecting: Boolean) {
val stringResource = if (isConnecting) R.string.connectivity_status_bar_connecting
else R.string.connectivity_status_bar_waiting_for_network

StatusLabel(stringResource)
}

@Composable
private fun OngoingCallContent(isMuted: Boolean) {
Row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ class CommonTopAppBarViewModel @Inject constructor(

var connectivityState by mutableStateOf(ConnectivityUIState(ConnectivityUIState.Info.None))

private suspend fun currentScreenFlow() = currentScreenManager.observeCurrentScreen(viewModelScope)

private fun connectivityFlow(userId: UserId): Flow<Connectivity> = coreLogic.sessionScope(userId) {
observeSyncState().map {
when (it) {
is SyncState.Failed, SyncState.Waiting -> Connectivity.WAITING_CONNECTION
SyncState.GatheringPendingEvents, SyncState.SlowSync -> Connectivity.CONNECTING
SyncState.Live -> Connectivity.CONNECTED
}
}
}
private suspend fun activeCallFlow(userId: UserId): Flow<Call?> = coreLogic.sessionScope(userId) {
calls.establishedCall().distinctUntilChanged().map { calls ->
calls.firstOrNull()
}
}

init {
viewModelScope.launch {
coreLogic.globalScope {
Expand Down Expand Up @@ -127,24 +144,6 @@ class CommonTopAppBarViewModel @Inject constructor(
}
}

private fun connectivityFlow(userId: UserId): Flow<Connectivity> = coreLogic.sessionScope(userId) {
observeSyncState().map {
when (it) {
is SyncState.Failed, SyncState.Waiting -> Connectivity.WAITING_CONNECTION
SyncState.GatheringPendingEvents, SyncState.SlowSync -> Connectivity.CONNECTING
SyncState.Live -> Connectivity.CONNECTED
}
}
}

private suspend fun activeCallFlow(userId: UserId): Flow<Call?> = coreLogic.sessionScope(userId) {
calls.establishedCall().distinctUntilChanged().map { calls ->
calls.firstOrNull()
}
}

private suspend fun currentScreenFlow() = currentScreenManager.observeCurrentScreen(viewModelScope)

private companion object {
const val WAITING_TIME_TO_SHOW_ONGOING_CALL_BANNER = 600L
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@
<string name="calling_feature_unavailable_message_alert">The option to initiate a conference call is only available in the paid version of Wire.</string>
<!-- Connectivity Status Bar -->
<string name="connectivity_status_bar_return_to_call">Return to call</string>
<string name="connectivity_status_bar_connecting">Connecting</string>
<string name="connectivity_status_bar_connecting">Decrypting messages</string>
<string name="connectivity_status_bar_waiting_for_network">Waiting for network</string>
<!-- Connections -->
<string name="connection_label_connect">Connect</string>
Expand Down

0 comments on commit 58341a1

Please sign in to comment.