From 36fd8d663f6d10cde2b9d5d0244c6b8ca001b2f4 Mon Sep 17 00:00:00 2001 From: AndroidBob Date: Mon, 27 Nov 2023 14:55:55 +0100 Subject: [PATCH] fix: hide search button in group conversation user profile [WPB-5656] (#2476) Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> --- .../userprofile/other/OtherUserProfileScreen.kt | 17 +++++------------ .../other/OtherUserProfileScreenViewModel.kt | 8 -------- .../userprofile/other/OtherUserProfileState.kt | 7 +++++++ 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt index 8664105d2b2..9f308cd6c9e 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt @@ -131,7 +131,6 @@ fun OtherUserProfileScreen( val conversationId = viewModel.state.conversationId ?: viewModel.state.conversationSheetContent?.conversationId - val shouldShowSearchButton = viewModel.shouldShowSearchButton(conversationId = conversationId) val onSearchConversationMessagesClick: () -> Unit = { conversationId?.let { navigator.navigate( @@ -160,7 +159,6 @@ fun OtherUserProfileScreen( onOpenConversation = { navigator.navigate(NavigationCommand(ConversationScreenDestination(it), BackStackMode.UPDATE_EXISTED)) }, onOpenDeviceDetails = { navigator.navigate(NavigationCommand(DeviceDetailsScreenDestination(navArgs.userId, it.clientId))) }, onSearchConversationMessagesClick = onSearchConversationMessagesClick, - shouldShowSearchButton = shouldShowSearchButton, navigateBack = navigator::navigateBack, navigationIconType = NavigationIconType.Close, ) @@ -194,7 +192,6 @@ fun OtherProfileScreenContent( onOpenConversation: (ConversationId) -> Unit = {}, onOpenDeviceDetails: (Device) -> Unit = {}, onSearchConversationMessagesClick: () -> Unit, - shouldShowSearchButton: Boolean, navigateBack: () -> Unit = {} ) { val otherUserProfileScreenState = rememberOtherUserProfileScreenState() @@ -272,8 +269,7 @@ fun OtherProfileScreenContent( topBarCollapsing = { TopBarCollapsing( state = state, - onSearchConversationMessagesClick = onSearchConversationMessagesClick, - shouldShowSearchButton = shouldShowSearchButton + onSearchConversationMessagesClick = onSearchConversationMessagesClick ) }, topBarFooter = { TopBarFooter(state, pagerState, tabBarElevationState, tabItems, currentTabState, scope) }, @@ -373,8 +369,7 @@ private fun TopBarHeader( @Composable private fun TopBarCollapsing( state: OtherUserProfileState, - onSearchConversationMessagesClick: () -> Unit, - shouldShowSearchButton: Boolean + onSearchConversationMessagesClick: () -> Unit ) { Crossfade( targetState = state, @@ -393,7 +388,7 @@ private fun TopBarCollapsing( connection = targetState.connectionState, isProteusVerified = targetState.isProteusVerified, onSearchConversationMessagesClick = onSearchConversationMessagesClick, - shouldShowSearchButton = shouldShowSearchButton + shouldShowSearchButton = state.shouldShowSearchButton() ) } } @@ -550,8 +545,7 @@ fun PreviewOtherProfileScreenContent() { closeBottomSheet = {}, eventsHandler = OtherUserProfileEventsHandler.PREVIEW, bottomSheetEventsHandler = OtherUserProfileBottomSheetEventsHandler.PREVIEW, - onSearchConversationMessagesClick = {}, - shouldShowSearchButton = false + onSearchConversationMessagesClick = {} ) } } @@ -571,8 +565,7 @@ fun PreviewOtherProfileScreenContentNotConnected() { closeBottomSheet = {}, eventsHandler = OtherUserProfileEventsHandler.PREVIEW, bottomSheetEventsHandler = OtherUserProfileBottomSheetEventsHandler.PREVIEW, - onSearchConversationMessagesClick = {}, - shouldShowSearchButton = false + onSearchConversationMessagesClick = {} ) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt index 22bdbdc652c..74dcf018d6d 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt @@ -54,7 +54,6 @@ import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.conversation.MutedConversationStatus import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.id.QualifiedID -import com.wire.kalium.logic.data.user.ConnectionState import com.wire.kalium.logic.data.user.UserId import com.wire.kalium.logic.feature.client.ObserveClientsByUserIdUseCase import com.wire.kalium.logic.feature.client.PersistOtherUserClientsUseCase @@ -394,11 +393,4 @@ class OtherUserProfileScreenViewModel @Inject constructor( } ) } - - fun shouldShowSearchButton(conversationId: ConversationId?): Boolean = - conversationId != null && state.connectionState in listOf( - ConnectionState.ACCEPTED, - ConnectionState.BLOCKED, - ConnectionState.MISSING_LEGALHOLD_CONSENT - ) } diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileState.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileState.kt index f67f21c7512..ceb7e606c63 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileState.kt @@ -75,6 +75,13 @@ data class OtherUserProfileState( fun isMetadataEmpty(): Boolean { return fullName.isEmpty() || userName.isEmpty() } + + fun shouldShowSearchButton(): Boolean = (groupState == null + && connectionState in listOf( + ConnectionState.ACCEPTED, + ConnectionState.BLOCKED, + ConnectionState.MISSING_LEGALHOLD_CONSENT + )) } data class OtherUserProfileGroupState(