Delegate "lastfile" management to ReadHistory (#6128)

Simplify (and avoid edge cases) in other code by having
ReadHistory manage the "lastfile" setting on add, remove,
rename...
Fixed a few other cases of things not updated.
This commit is contained in:
poire-z
2020-05-06 21:11:34 +02:00
committed by GitHub
parent 48727a984b
commit 46221985a6
9 changed files with 75 additions and 69 deletions

View File

@@ -72,16 +72,7 @@ function ReaderMenu:init()
end
function ReaderMenu:getPreviousFile()
local previous_file = nil
local readhistory = require("readhistory")
for i=2, #readhistory.hist do -- skip first one which is current book
-- skip deleted items kept in history
if lfs.attributes(readhistory.hist[i].file, "mode") == "file" then
previous_file = readhistory.hist[i].file
break
end
end
return previous_file
return require("readhistory"):getPreviousFile(self.ui.document.file)
end
function ReaderMenu:onReaderReady()