From 788d4e0c521fc9a79adff28706fbce5da30f6358 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sat, 7 Feb 2026 17:28:37 +0200 Subject: [PATCH] Fix long-pressing on unopened book with status (#14947) --- frontend/apps/filemanager/filemanager.lua | 13 ++++++++----- .../apps/filemanager/filemanagercollection.lua | 15 +++++++++------ .../filemanager/filemanagerfilesearcher.lua | 17 +++++++++++++---- .../apps/filemanager/filemanagerhistory.lua | 13 ++++++++----- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/frontend/apps/filemanager/filemanager.lua b/frontend/apps/filemanager/filemanager.lua index bfabc6a96..b2da41235 100644 --- a/frontend/apps/filemanager/filemanager.lua +++ b/frontend/apps/filemanager/filemanager.lua @@ -286,11 +286,14 @@ function FileManager:setupLayout() FileManagerConverter:genConvertButton(file, close_dialog_callback, refresh_callback) }) end - if been_opened and #doc_settings_or_file:readSetting("annotations") > 0 then - table.insert(buttons, { - file_manager.collections:genExportHighlightsButton({ [file] = true }, close_dialog_callback), - file_manager.collections:genBookmarkBrowserButton({ [file] = true }, close_dialog_callback), - }) + if been_opened then + local annotations = doc_settings_or_file:readSetting("annotations") + if annotations and #annotations > 0 then + table.insert(buttons, { + file_manager.collections:genExportHighlightsButton({ [file] = true }, close_dialog_callback), + file_manager.collections:genBookmarkBrowserButton({ [file] = true }, close_dialog_callback), + }) + end end table.insert(buttons, { { diff --git a/frontend/apps/filemanager/filemanagercollection.lua b/frontend/apps/filemanager/filemanagercollection.lua index 419e05c83..f68954800 100644 --- a/frontend/apps/filemanager/filemanagercollection.lua +++ b/frontend/apps/filemanager/filemanagercollection.lua @@ -286,11 +286,14 @@ function FileManagerCollection:onMenuHold(item) end, }, }) - if been_opened and #doc_settings_or_file:readSetting("annotations") > 0 then - table.insert(buttons, { - self._manager:genExportHighlightsButton({ [file] = true }, close_dialog_callback), - self._manager:genBookmarkBrowserButton({ [file] = true }, close_dialog_callback), - }) + if been_opened then + local annotations = doc_settings_or_file:readSetting("annotations") + if annotations and #annotations > 0 then + table.insert(buttons, { + self._manager:genExportHighlightsButton({ [file] = true }, close_dialog_callback), + self._manager:genBookmarkBrowserButton({ [file] = true }, close_dialog_callback), + }) + end end table.insert(buttons, { filemanagerutil.genShowFolderButton(file, close_dialog_menu_callback), @@ -1556,7 +1559,7 @@ end function FileManagerCollection:genExportHighlightsButton(files, caller_pre_callback, button_disabled) return { text = _("Export highlights"), - enabled = self.ui.exporter and not button_disabled or false, + enabled = (self.ui.exporter and self.ui.exporter:isReady()) and not button_disabled or false, callback = function() if caller_pre_callback then caller_pre_callback() diff --git a/frontend/apps/filemanager/filemanagerfilesearcher.lua b/frontend/apps/filemanager/filemanagerfilesearcher.lua index d6fc82fd7..a0c89e34d 100644 --- a/frontend/apps/filemanager/filemanagerfilesearcher.lua +++ b/frontend/apps/filemanager/filemanagerfilesearcher.lua @@ -340,7 +340,7 @@ function FileSearcher:onMenuSelect(item) if item.is_file then item.dim = not item.dim and true or nil self._manager.selected_files[item.path] = item.dim - self._manager:updateItemTable() + self:updateItems(1, true) end else if item.is_file then @@ -449,6 +449,15 @@ function FileSearcher:onMenuHold(item) end, }, }) + if been_opened then + local annotations = doc_settings_or_file:readSetting("annotations") + if annotations and #annotations > 0 then + table.insert(buttons, { + self._manager.ui.collections:genExportHighlightsButton({ [file] = true }, close_dialog_callback), + self._manager.ui.collections:genBookmarkBrowserButton({ [file] = true }, close_dialog_callback), + }) + end + end table.insert(buttons, { filemanagerutil.genShowFolderButton(file, close_dialog_menu_callback), filemanagerutil.genBookInformationButton(doc_settings_or_file, book_props, close_dialog_callback), @@ -517,7 +526,7 @@ function FileSearcher:showSelectModeDialog() for _, item in ipairs(item_table) do item.dim = nil end - self:updateItemTable() + self.booklist_menu:updateItems(1, true) end, }, { @@ -530,7 +539,7 @@ function FileSearcher:showSelectModeDialog() self.selected_files[item.path] = true end end - self:updateItemTable() + self.booklist_menu:updateItems(1, true) end, }, }, @@ -546,7 +555,7 @@ function FileSearcher:showSelectModeDialog() item.dim = nil end end - self:updateItemTable() + self.booklist_menu:updateItems(1, true) end, }, { diff --git a/frontend/apps/filemanager/filemanagerhistory.lua b/frontend/apps/filemanager/filemanagerhistory.lua index 222ea6cfc..753a839c0 100644 --- a/frontend/apps/filemanager/filemanagerhistory.lua +++ b/frontend/apps/filemanager/filemanagerhistory.lua @@ -256,11 +256,14 @@ function FileManagerHistory:onMenuHold(item) end, }, }) - if been_opened and #doc_settings_or_file:readSetting("annotations") > 0 then - table.insert(buttons, { - self._manager.ui.collections:genExportHighlightsButton({ [file] = true }, close_dialog_callback), - self._manager.ui.collections:genBookmarkBrowserButton({ [file] = true }, close_dialog_callback), - }) + if been_opened then + local annotations = doc_settings_or_file:readSetting("annotations") + if annotations and #annotations > 0 then + table.insert(buttons, { + self._manager.ui.collections:genExportHighlightsButton({ [file] = true }, close_dialog_callback), + self._manager.ui.collections:genBookmarkBrowserButton({ [file] = true }, close_dialog_callback), + }) + end end table.insert(buttons, { filemanagerutil.genShowFolderButton(file, close_dialog_menu_callback, item.dim),