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: wrong service opens when clicking on search result [WPB-11330] #3476

Merged
Merged
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 @@ -39,24 +39,25 @@ import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.progress.CenteredCircularProgressBarIndicator
import com.wire.android.ui.home.conversations.search.widget.SearchFailureBox
import com.wire.android.ui.home.newconversation.model.Contact
import com.wire.android.util.extension.folderWithElements
import kotlinx.collections.immutable.ImmutableList

@Composable
fun SearchAllServicesScreen(
searchQuery: String,
onServiceClicked: (Contact) -> Unit,
searchServicesViewModel: SearchServicesViewModel = hiltViewModel(),
lazyListState: LazyListState = rememberLazyListState(),
) {
LaunchedEffect(key1 = searchQuery) {
searchServicesViewModel.searchQueryChanged(searchQuery)
}

val lazyState = rememberLazyListState()
SearchAllServicesContent(
searchQuery = searchServicesViewModel.state.searchQuery,
onServiceClicked = onServiceClicked,
result = searchServicesViewModel.state.result,
lazyListState = lazyState,
lazyListState = lazyListState,
error = searchServicesViewModel.state.error,
isLoading = searchServicesViewModel.state.isLoading
)
Expand Down Expand Up @@ -106,36 +107,35 @@ private fun SuccessServicesList(
modifier = Modifier
.weight(1f)
) {
services
.forEach {
item {
RowItemTemplate(
leadingIcon = {
Row {
UserProfileAvatar(it.avatarData)
}
},
titleStartPadding = dimensions().spacing0x,
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
HighlightName(
name = it.name,
searchQuery = searchQuery,
modifier = Modifier.weight(weight = 1f, fill = false)
)
UserBadge(
membership = it.membership,
connectionState = it.connectionState,
startPadding = dimensions().spacing8x
)
}
},
actions = {},
clickable = remember { Clickable(enabled = true) { onServiceClicked(it) } },
modifier = Modifier.padding(start = dimensions().spacing8x)
)
}
}
folderWithElements(
items = services.associateBy { it.id }
) {
RowItemTemplate(
leadingIcon = {
Row {
UserProfileAvatar(it.avatarData)
}
},
titleStartPadding = dimensions().spacing0x,
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
HighlightName(
name = it.name,
searchQuery = searchQuery,
modifier = Modifier.weight(weight = 1f, fill = false)
)
UserBadge(
membership = it.membership,
connectionState = it.connectionState,
startPadding = dimensions().spacing8x
)
}
},
actions = {},
clickable = remember(it) { Clickable(enabled = true) { onServiceClicked(it) } },
modifier = Modifier.padding(start = dimensions().spacing8x)
)
}
}
}
}
Loading