Skip to content

Commit

Permalink
fix: hide search button in group conversation user profile [WPB-5656] (
Browse files Browse the repository at this point in the history
…#2476)

Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
AndroidBob and github-actions[bot] authored Nov 27, 2023
1 parent e78f845 commit 36fd8d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -194,7 +192,6 @@ fun OtherProfileScreenContent(
onOpenConversation: (ConversationId) -> Unit = {},
onOpenDeviceDetails: (Device) -> Unit = {},
onSearchConversationMessagesClick: () -> Unit,
shouldShowSearchButton: Boolean,
navigateBack: () -> Unit = {}
) {
val otherUserProfileScreenState = rememberOtherUserProfileScreenState()
Expand Down Expand Up @@ -272,8 +269,7 @@ fun OtherProfileScreenContent(
topBarCollapsing = {
TopBarCollapsing(
state = state,
onSearchConversationMessagesClick = onSearchConversationMessagesClick,
shouldShowSearchButton = shouldShowSearchButton
onSearchConversationMessagesClick = onSearchConversationMessagesClick
)
},
topBarFooter = { TopBarFooter(state, pagerState, tabBarElevationState, tabItems, currentTabState, scope) },
Expand Down Expand Up @@ -373,8 +369,7 @@ private fun TopBarHeader(
@Composable
private fun TopBarCollapsing(
state: OtherUserProfileState,
onSearchConversationMessagesClick: () -> Unit,
shouldShowSearchButton: Boolean
onSearchConversationMessagesClick: () -> Unit
) {
Crossfade(
targetState = state,
Expand All @@ -393,7 +388,7 @@ private fun TopBarCollapsing(
connection = targetState.connectionState,
isProteusVerified = targetState.isProteusVerified,
onSearchConversationMessagesClick = onSearchConversationMessagesClick,
shouldShowSearchButton = shouldShowSearchButton
shouldShowSearchButton = state.shouldShowSearchButton()
)
}
}
Expand Down Expand Up @@ -550,8 +545,7 @@ fun PreviewOtherProfileScreenContent() {
closeBottomSheet = {},
eventsHandler = OtherUserProfileEventsHandler.PREVIEW,
bottomSheetEventsHandler = OtherUserProfileBottomSheetEventsHandler.PREVIEW,
onSearchConversationMessagesClick = {},
shouldShowSearchButton = false
onSearchConversationMessagesClick = {}
)
}
}
Expand All @@ -571,8 +565,7 @@ fun PreviewOtherProfileScreenContentNotConnected() {
closeBottomSheet = {},
eventsHandler = OtherUserProfileEventsHandler.PREVIEW,
bottomSheetEventsHandler = OtherUserProfileBottomSheetEventsHandler.PREVIEW,
onSearchConversationMessagesClick = {},
shouldShowSearchButton = false
onSearchConversationMessagesClick = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 36fd8d6

Please sign in to comment.