Fix "Open next file" (#11272)

reviewable/pr11282/r1
hius07 5 months ago committed by GitHub
parent b949d07f4f
commit 7a421ea3ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -169,12 +169,8 @@ function ReaderStatus:openFileBrowser()
end
function ReaderStatus:onOpenNextDocumentInFolder()
local FileManager = require("apps/filemanager/filemanager")
if not FileManager.instance then
self.ui:showFileManager()
end
local next_file = FileManager.instance.file_chooser:getNextFile(self.document.file)
FileManager.instance:onClose()
local FileChooser = require("ui/widget/filechooser")
local next_file = FileChooser:getNextFile(self.document.file)
if next_file then
self.ui:switchDocument(next_file)
else

@ -225,8 +225,8 @@ function FileChooser:show_file(filename, fullpath)
for _, pattern in ipairs(self.exclude_files) do
if filename:match(pattern) then return false end
end
if not self.show_unsupported and self.file_filter ~= nil and not self.file_filter(filename) then return false end
if not self.show_finished and fullpath ~= nil and filemanagerutil.getStatus(fullpath) == "complete" then return false end
if not FileChooser.show_unsupported and self.file_filter ~= nil and not self.file_filter(filename) then return false end
if not FileChooser.show_finished and fullpath ~= nil and filemanagerutil.getStatus(fullpath) == "complete" then return false end
return true
end
@ -243,7 +243,7 @@ function FileChooser:getList(path, collate)
if ok then
unreadable_dir_content[path] = nil
for f in iter, dir_obj do
if self.show_hidden or not util.stringStartsWith(f, ".") then
if FileChooser.show_hidden or not util.stringStartsWith(f, ".") then
local fullpath = path.."/"..f
local attributes = lfs.attributes(fullpath) or {}
local item = true
@ -559,14 +559,20 @@ end
-- Used in ReaderStatus:onOpenNextDocumentInFolder().
function FileChooser:getNextFile(curr_file)
local show_finished = FileChooser.show_finished
FileChooser.show_finished = true
local curr_path = curr_file:match(".*/"):gsub("/$", "")
local item_table = self:genItemTableFromPath(curr_path)
FileChooser.show_finished = show_finished
local is_curr_file_found
for i, item in ipairs(self.item_table) do
for i, item in ipairs(item_table) do
if not is_curr_file_found and item.path == curr_file then
is_curr_file_found = true
end
if is_curr_file_found then
local next_file = self.item_table[i+1]
if next_file and next_file.is_file and DocumentRegistry:hasProvider(next_file.path) then
local next_file = item_table[i+1]
if next_file and next_file.is_file and DocumentRegistry:hasProvider(next_file.path)
and filemanagerutil.getStatus(next_file.path) ~= "complete" then
return next_file.path
end
end

Loading…
Cancel
Save