Disabe search in encrypted room

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-01-17 10:15:13 +05:30
parent 9f3f877bfd
commit 8c30a013c7
2 changed files with 23 additions and 17 deletions

View file

@ -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,8 +150,7 @@ function RoomSearch({ roomId }) {
{searchData?.results.length > 0 && (
<Text>{`${searchData.count} results for "${searchTerm}"`}</Text>
)}
</form>
{searchData === null && (
{!isRoomEncrypted && searchData === null && (
<div className="room-search__help">
{status.type === cons.status.IN_FLIGHT && <Spinner />}
{status.type === cons.status.IN_FLIGHT && <Text>Searching room messages...</Text>}
@ -159,11 +160,17 @@ function RoomSearch({ roomId }) {
</div>
)}
{searchData?.results.length === 0 && (
{!isRoomEncrypted && searchData?.results.length === 0 && (
<div className="room-search__help">
<Text>No result found</Text>
</div>
)}
{isRoomEncrypted && (
<div className="room-search__help">
<Text>Search does not work in encrypted room</Text>
</div>
)}
</form>
{searchData?.results.length > 0 && (
<>
<div className="room-search__content">

View file

@ -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;
}