From b90738693340846b0e8fdbd1e4bde9c36e6c8251 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Thu, 1 Apr 2021 14:19:36 +0300 Subject: [PATCH] Fulltext search: show notification when nothing found (#7436) --- frontend/apps/reader/modules/readersearch.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/apps/reader/modules/readersearch.lua b/frontend/apps/reader/modules/readersearch.lua index 3c109b8d5..49d11041d 100644 --- a/frontend/apps/reader/modules/readersearch.lua +++ b/frontend/apps/reader/modules/readersearch.lua @@ -2,6 +2,7 @@ local BD = require("ui/bidi") local ButtonDialog = require("ui/widget/buttondialog") local InputContainer = require("ui/widget/container/inputcontainer") local InputDialog = require("ui/widget/inputdialog") +local Notification = require("ui/widget/notification") local UIManager = require("ui/uimanager") local logger = require("logger") local _ = require("gettext") @@ -73,9 +74,11 @@ function ReaderSearch:onShowSearchDialog(text, direction) local current_page local do_search = function(search_func, _text, param) return function() + local no_results = true -- for notification local res = search_func(self, _text, param) if res then if self.ui.document.info.has_pages then + no_results = false self.ui.link:onGotoLink({page = res.page - 1}, neglect_current_location) self.view.highlight.temp[res.page] = res else @@ -139,12 +142,24 @@ function ReaderSearch:onShowSearchDialog(text, direction) end end if valid_link then + no_results = false self.ui.link:onGotoLink({xpointer=valid_link}, neglect_current_location) end end -- Don't add result pages to location ("Go back") stack neglect_current_location = true end + if no_results then + local notification_text + if self._expect_back_results then + notification_text = _("No results on preceding pages") + else + notification_text = _("No results on following pages") + end + UIManager:show(Notification:new{ + text = notification_text, + }) + end end end local from_start_text = "▕◁"