2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

ReaderDictionary: show nothing if interrupted quickly

If interrupted quickly just after lookup launch, don't
display anything (this might help avoiding refreshes
and the need to dismiss after accidental long-press
when manipulating the device).
This commit is contained in:
poire-z 2020-12-22 18:45:32 +01:00
parent cac7db1a1c
commit b66d0be3f9

View File

@ -781,6 +781,8 @@ function ReaderDictionary:startSdcv(word, dict_names, fuzzy_search)
dict = "",
word = word,
definition = lookup_cancelled and _("Dictionary lookup canceled.") or _("No definition found."),
no_result = true,
lookup_cancelled = lookup_cancelled,
}
}
end
@ -822,7 +824,18 @@ function ReaderDictionary:stardictLookup(word, dict_names, fuzzy_search, box, li
self:showLookupInfo(word, 0.5)
local lookup_start_ts = ffiUtil.getTimestamp()
local results = self:startSdcv(word, dict_names, fuzzy_search)
if results and results[1] and results[1].lookup_cancelled and ffiUtil.getDuration(lookup_start_ts) < 1.5 then
-- If interrupted quickly just after launch, don't display anything
-- (this might help avoiding refreshes and the need to dismiss
-- after accidental long-press when holding a device).
if self.highlight then
self.highlight:clear()
end
return
end
self:showDict(word, tidyMarkup(results), box, link)
end