Merge pull request #5141 from vector-im/feature/mna/4641-remove-room-search-menu

Issue-4641: Show search menu item only if available
This commit is contained in:
Benoit Marty 2022-02-03 11:13:11 +01:00 committed by GitHub
commit cd6ba5265b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 12 deletions

1
changelog.d/4641.misc Normal file
View File

@ -0,0 +1 @@
Remove Search from room options if not available

View File

@ -85,6 +85,8 @@ data class RoomDetailViewState(
fun isWebRTCCallOptionAvailable() = (asyncRoomSummary.invoke()?.joinedMembersCount ?: 0) <= 2
fun isSearchAvailable() = asyncRoomSummary()?.isEncrypted == false
// This checks directly on the active room widgets.
// It can differs for a short period of time on the JitsiState as its computed async.
fun hasActiveJitsiWidget() = activeRoomWidgets()?.any { it.type == WidgetType.Jitsi && it.isActive }.orFalse()

View File

@ -1141,16 +1141,12 @@ class TimelineFragment @Inject constructor(
}
private fun handleSearchAction() {
if (session.getRoom(timelineArgs.roomId)?.isEncrypted() == false) {
navigator.openSearch(
context = requireContext(),
roomId = timelineArgs.roomId,
roomDisplayName = timelineViewModel.getRoomSummary()?.displayName,
roomAvatarUrl = timelineViewModel.getRoomSummary()?.avatarUrl
)
} else {
showDialogWithMessage(getString(R.string.search_is_not_supported_in_e2e_room))
}
navigator.openSearch(
context = requireContext(),
roomId = timelineArgs.roomId,
roomDisplayName = timelineViewModel.getRoomSummary()?.displayName,
roomAvatarUrl = timelineViewModel.getRoomSummary()?.avatarUrl
)
}
private fun displayDisabledIntegrationDialog() {
@ -1926,7 +1922,7 @@ class TimelineFragment @Inject constructor(
timelineViewModel.handle(action)
}
is EncryptedEventContent -> {
timelineViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId))
timelineViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId))
}
is MessageLocationContent -> {
handleShowLocationPreview(messageContent, informationData.senderId)

View File

@ -720,7 +720,7 @@ class TimelineViewModel @AssistedInject constructor(
R.id.video_call -> state.isWebRTCCallOptionAvailable() || state.jitsiState.confId == null || state.jitsiState.hasJoined
// Show Join conference button only if there is an active conf id not joined. Otherwise fallback to default video disabled. ^
R.id.join_conference -> !state.isWebRTCCallOptionAvailable() && state.jitsiState.confId != null && !state.jitsiState.hasJoined
R.id.search -> true
R.id.search -> state.isSearchAvailable()
R.id.menu_timeline_thread_list -> vectorPreferences.areThreadMessagesEnabled()
R.id.dev_tools -> vectorPreferences.developerMode()
else -> false

View File

@ -1064,6 +1064,7 @@
<string name="tab_title_search_messages">MESSAGES</string>
<string name="tab_title_search_people">PEOPLE</string>
<string name="tab_title_search_files">FILES</string>
<!-- TODO TO BE REMOVED -->
<string name="search_is_not_supported_in_e2e_room">Searching in encrypted rooms is not supported yet.</string>
<!-- Directory -->