From 8c30a013c7c2d95b6f90c345c652342c303580b8 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Mon, 17 Jan 2022 10:15:13 +0530 Subject: [PATCH] Disabe search in encrypted room Signed-off-by: Ajay Bura --- src/app/molecules/room-search/RoomSearch.jsx | 39 ++++++++++++-------- src/app/organisms/room/RoomSettings.scss | 1 - 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/app/molecules/room-search/RoomSearch.jsx b/src/app/molecules/room-search/RoomSearch.jsx index cbbaf23..39b83b4 100644 --- a/src/app/molecules/room-search/RoomSearch.jsx +++ b/src/app/molecules/room-search/RoomSearch.jsx @@ -104,10 +104,12 @@ function useRoomSearch(roomId) { function RoomSearch({ roomId }) { const [searchData, search, paginate, status] = useRoomSearch(roomId); - + const mx = initMatrix.matrixClient; + const isRoomEncrypted = mx.isRoomEncrypted(roomId); const searchTerm = searchData?._query.search_categories.room_events.search_term ?? ''; const handleSearch = (e) => { + if (isRoomEncrypted) return; e.preventDefault(); const searchTermInput = e.target.elements['room-search-input']; const term = searchTermInput.value.trim(); @@ -148,22 +150,27 @@ function RoomSearch({ roomId }) { {searchData?.results.length > 0 && ( {`${searchData.count} results for "${searchTerm}"`} )} - - {searchData === null && ( -
- {status.type === cons.status.IN_FLIGHT && } - {status.type === cons.status.IN_FLIGHT && Searching room messages...} - {status.type === cons.status.PRE_FLIGHT && } - {status.type === cons.status.PRE_FLIGHT && Search room messages} - {status.type === cons.status.ERROR && Failed to search messages} -
- )} + {!isRoomEncrypted && searchData === null && ( +
+ {status.type === cons.status.IN_FLIGHT && } + {status.type === cons.status.IN_FLIGHT && Searching room messages...} + {status.type === cons.status.PRE_FLIGHT && } + {status.type === cons.status.PRE_FLIGHT && Search room messages} + {status.type === cons.status.ERROR && Failed to search messages} +
+ )} - {searchData?.results.length === 0 && ( -
- No result found -
- )} + {!isRoomEncrypted && searchData?.results.length === 0 && ( +
+ No result found +
+ )} + {isRoomEncrypted && ( +
+ Search does not work in encrypted room +
+ )} + {searchData?.results.length > 0 && ( <>
diff --git a/src/app/organisms/room/RoomSettings.scss b/src/app/organisms/room/RoomSettings.scss index 909dbb3..fb1b251 100644 --- a/src/app/organisms/room/RoomSettings.scss +++ b/src/app/organisms/room/RoomSettings.scss @@ -48,7 +48,6 @@ .room-settings .room-permissions__card, .room-settings .room-search__form, -.room-settings .room-search__help, .room-settings .room-search__result-item { @extend .room-settings__card; } \ No newline at end of file