2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

ReadHistory: On remove, trust the index from FileManagerHistory if possible (#12253)

The item's idx field is based on the current view settings, so only trust it when there's no filtering or searches involved, which ensures the order matches the actual history array layout.
This commit is contained in:
NiLuJe 2024-08-03 21:49:11 +02:00 committed by GitHub
parent f6f8b38cac
commit 030f4a15d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -207,7 +207,12 @@ function FileManagerHistory:onMenuHold(item)
text = _("Remove from history"),
callback = function()
UIManager:close(self.histfile_dialog)
require("readhistory"):removeItem(item)
-- The item's idx field is tied to the current *view*, so we can only pass it as-is when there's no filtering *at all* involved.
local index = item.idx
if self._manager.search_string or self._manager.selected_colections or self._manager.filter ~= "all" then
index = nil
end
require("readhistory"):removeItem(item, index)
self._manager:updateItemTable()
end,
},