From 7a421ea3ab8a4e2386dcec906e346ba4fd465ad8 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Wed, 27 Dec 2023 08:45:52 +0200 Subject: [PATCH] Fix "Open next file" (#11272) --- frontend/apps/reader/modules/readerstatus.lua | 8 ++------ frontend/ui/widget/filechooser.lua | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/frontend/apps/reader/modules/readerstatus.lua b/frontend/apps/reader/modules/readerstatus.lua index 876100510..138ed0529 100644 --- a/frontend/apps/reader/modules/readerstatus.lua +++ b/frontend/apps/reader/modules/readerstatus.lua @@ -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 diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index 701422181..3c5fa497d 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -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