Searching: Return an empty result if the search term is an empty string.

This mimics the behaviour we get from synapse as, this fixes
https://github.com/vector-im/riot-web/issues/12715.
This commit is contained in:
Damir Jelić 2020-03-20 11:38:43 +01:00
parent 20d0e8a888
commit 759f71cb53

View file

@ -87,6 +87,13 @@ async function localSearch(searchTerm, roomId = undefined) {
searchArgs.room_id = roomId;
}
const emptyResult = {
results: [],
highlights: [],
};
if (searchTerm === "") return emptyResult;
const eventIndex = EventIndexPeg.get();
const localResult = await eventIndex.search(searchArgs);
@ -97,11 +104,6 @@ async function localSearch(searchTerm, roomId = undefined) {
},
};
const emptyResult = {
results: [],
highlights: [],
};
const result = MatrixClientPeg.get()._processRoomEventsSearch(
emptyResult, response);