Open previous file in last book folder (#13424)
Some checks are pending
macos / macOS 13 x86-64 🔨15.2 🎯10.15 (push) Waiting to run
macos / macOS 14 ARM64 🔨15.4 🎯11.0 (push) Waiting to run

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

View File

@@ -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()