Content server book viewer: Show a message when a search finds no matches

This commit is contained in:
Kovid Goyal 2021-08-20 20:18:09 +05:30
parent 4382ae8cbe
commit b814eae1fd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

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