Open previous file in last book folder (#13424)

This commit is contained in:
hius07 authored and GitHub committed 2025-03-18 07:50:48 +02:00
1 parent fab3a4383e
commit e8ccd922d8
4 files changed
+43 -18

No files matched your search

@@ -171,20 +171,24 @@ function ReaderStatus:openFileBrowser()
self.ui:showFileManager(file)
end
function ReaderStatus:onOpenNextDocumentInFolder()
function ReaderStatus:onOpenNextOrPreviousFileInFolder(prev)
local collate = G_reader_settings:readSetting("collate")
if collate == "access" or collate == "date" then return true end
local FileChooser = require("ui/widget/filechooser")
local next_file = FileChooser:getNextFile(self.document.file)
if next_file then
local file = FileChooser:getNextOrPreviousFileInFolder(self.document.file, prev)
if file then
-- Delay until the next tick, as this will destroy the Document instance,
-- but we may not be the final Event caught by said Document...
UIManager:nextTick(function()
self.ui:switchDocument(next_file)
self.ui:switchDocument(file)
end)
else
UIManager:show(InfoMessage:new{
text = _("This is the last file in the current folder. No next file to open."),
text = prev and _("This is the first file in the folder. No previous file to open.")
or _("This is the last file in the folder. No next file to open."),
})
end
return true
end
function ReaderStatus:deleteFile()