From 5d88ef08eb2d45fc892a0cf1718855d02364e2ef Mon Sep 17 00:00:00 2001 From: Diogo Date: Fri, 30 Aug 2024 22:51:11 +0100 Subject: [PATCH] hosts ordering and fixes --- .../common/views/chatlist/UserPicker.kt | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt index c69c99d398..64ef2c0980 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt @@ -616,18 +616,32 @@ private fun DevicePickerRow( horizontalArrangement = Arrangement.spacedBy(12.dp), verticalAlignment = Alignment.CenterVertically ) { + val activeHost = remoteHosts.firstOrNull { h -> h.activeHost } + + if (activeHost != null) { + val connecting = rememberSaveable { mutableStateOf(false) } - if (localDeviceActive) { DevicePill( active = true, - icon = painterResource(MR.images.ic_desktop), - text = stringResource(MR.strings.this_device), - actionButtonVisible = false + icon = painterResource(MR.images.ic_smartphone_300), + text = activeHost.hostDeviceName, + actionButtonVisible = activeHost.sessionState is RemoteHostSessionState.Connected, + onActionButtonClick = { onRemoteHostActionButtonClick(activeHost) } ) { - onLocalDeviceClick() + onRemoteHostClick(activeHost, connecting) } } - remoteHosts.filter { h -> h.activeHost }.forEach { h -> + + DevicePill( + active = localDeviceActive, + icon = painterResource(MR.images.ic_desktop), + text = stringResource(MR.strings.this_device), + actionButtonVisible = false + ) { + onLocalDeviceClick() + } + + remoteHosts.filter { h -> h.sessionState is RemoteHostSessionState.Connected && !h.activeHost }.forEach { h -> val connecting = rememberSaveable { mutableStateOf(false) } DevicePill( @@ -640,17 +654,6 @@ private fun DevicePickerRow( onRemoteHostClick(h, connecting) } } - - if (!localDeviceActive) { - DevicePill( - active = false, - icon = painterResource(MR.images.ic_desktop), - text = stringResource(MR.strings.this_device), - actionButtonVisible = false - ) { - onLocalDeviceClick() - } - } } }