diff --git a/changelog.d/4641.misc b/changelog.d/4641.misc
new file mode 100644
index 0000000000..f02bf14fc1
--- /dev/null
+++ b/changelog.d/4641.misc
@@ -0,0 +1 @@
+Remove Search from room options if not available
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt
index c63085f647..22d5fc2a77 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt
@@ -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()
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt
index 93af33fd4a..d626d87698 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt
@@ -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)
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt
index 0001d35db2..7d678520ec 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt
@@ -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
diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml
index 1bcf150f2c..67f3a08e5f 100644
--- a/vector/src/main/res/values/strings.xml
+++ b/vector/src/main/res/values/strings.xml
@@ -1064,6 +1064,7 @@
MESSAGES
PEOPLE
FILES
+
Searching in encrypted rooms is not supported yet.