Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
search: allow empty term
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Fentker <jonas@fentker.eu>
  • Loading branch information
Pestdoktor committed Jul 8, 2020
1 parent cbdbdb6 commit d535efe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
23 changes: 13 additions & 10 deletions src/Searching.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ async function serverSideSearch(term, roomId = undefined, senderId = undefined)
if (roomId !== undefined) filter.rooms = [roomId];
if (senderId !== undefined) filter.senders = [senderId];

const room_events = {
filter: filter,
order_by: "recent",
event_context: {
before_limit: 1,
after_limit: 1,
include_profile: true,
},
};

if (term !== "") room_events.search_term = term;

const body = {
search_categories: {
room_events: {
search_term: term,
filter: filter,
order_by: "recent",
event_context: {
before_limit: 1,
after_limit: 1,
include_profile: true,
},
},
room_events: room_events,
},
};

Expand Down
5 changes: 3 additions & 2 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,9 @@ export default createReactClass({
// whether it was used by the search engine or not.

let highlights = results.highlights;
if (highlights.indexOf(self.state.searchTerm) < 0) {
highlights = highlights.concat(self.state.searchTerm);
let searchTerm = self.state.searchTerm ;
if (searchTerm !== "" && highlights.indexOf(searchTerm) < 0) {
highlights = highlights.concat(searchTerm);
}

// For overlapping highlights,
Expand Down

0 comments on commit d535efe

Please sign in to comment.