From b814eae1fd3e4e960e549bb623d213992e0955f5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 Aug 2021 20:18:09 +0530 Subject: [PATCH] Content server book viewer: Show a message when a search finds no matches --- src/pyj/read_book/search.pyj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pyj/read_book/search.pyj b/src/pyj/read_book/search.pyj index 804ae917d5..2a21b43a23 100644 --- a/src/pyj/read_book/search.pyj +++ b/src/pyj/read_book/search.pyj @@ -213,9 +213,17 @@ class SearchOverlay: elif msg.id is self.search_in_flight.id: if msg.type is 'search_complete': self.search_in_flight.id = None + if Object.keys(self.result_map).length is 0: + self.no_result_received() elif msg.type is 'search_result': self.result_received(msg.result) + def no_result_received(self): + self.show_results() + self.results_container.appendChild(E.div( + style='margin: 1rem', + _('No matching results found'))) + def result_received(self, result): self.show_results() self.result_map[result.result_num] = result