Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide search button in group conversation user profile [WPB-5656] #2476

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading