mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
On pressing Back crereader loses last position
This fix makes the behaviour of Back command handler in crereader identical with that in unireader, i.e. the last position is saved in Jump History when pressing Back, so you can return to it by pressing Shift-Back enough times. Also, with this change we would need to handle the need for redrawing the current page because the :addJump() method can force the call to fillToc() (if TOC is not already present) and this will display "Retrieving TOC..." message which will need clearing away.
This commit is contained in:
@@ -636,12 +636,29 @@ function CREReader:adjustCreReaderCommands()
|
||||
self.commands:add(KEY_BACK, nil, "Back",
|
||||
"go backward in jump history",
|
||||
function(self)
|
||||
local prev_jump_no = self.jump_history.cur - 1
|
||||
local prev_jump_no = 0
|
||||
local need_refresh = false
|
||||
if self.jump_history.cur > #self.jump_history then
|
||||
-- addJump() will cause a "Retrieving TOC..." msg, so we'll
|
||||
-- need to redraw the page after our own
|
||||
-- ifo msg "Already first jump!" below
|
||||
if not self.toc then need_refresh = true end
|
||||
|
||||
-- if cur points to head, put current page in history
|
||||
self:addJump(self.doc:getXPointer())
|
||||
prev_jump_no = self.jump_history.cur - 2
|
||||
else
|
||||
prev_jump_no = self.jump_history.cur - 1
|
||||
end
|
||||
|
||||
if prev_jump_no >= 1 then
|
||||
self.jump_history.cur = prev_jump_no
|
||||
self:goto(self.jump_history[prev_jump_no].page, true, "xpointer")
|
||||
else
|
||||
showInfoMsgWithDelay("Already first jump!", 2000, 1)
|
||||
if need_refresh then
|
||||
self:redrawCurrentPage()
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user