CoverBrowser: fix some button callback overrides (#9647)

Broken since b0eb0ce0: the custom callbacks for the "Reset settings"
& "Book information" buttons are not being called anymore because
patching those is done to early (before instead of after creating
the new modified dialog).
reviewable/pr9662/r1
Benoit Pierre 2 years ago committed by GitHub
parent effddbc1ee
commit 1d6f4acad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -238,25 +238,6 @@ function CoverMenu:updateItems(select_number)
-- And clear the rendering stack to avoid inheriting its dirty/refresh queue
UIManager:clearRenderStack()
-- Fudge the "Reset settings" button callback to also trash the cover_info_cache
local button = self.file_dialog.button_table:getButtonById("reset_settings")
local orig_purge_callback = button.callback
button.callback = function()
-- Wipe the cache
if self.cover_info_cache and self.cover_info_cache[file] then
self.cover_info_cache[file] = nil
end
-- And then purge the sidecar folder as expected
orig_purge_callback()
end
-- Replace the "Book information" button callback to use directly our bookinfo
button = self.file_dialog.button_table:getButtonById("book_information")
button.callback = function()
FileManagerBookInfo:show(file, bookinfo)
UIManager:close(self.file_dialog)
end
-- Add some new buttons to original buttons set
table.insert(orig_buttons, {
{ -- Allow user to view real size cover in ImageViewer
@ -398,6 +379,26 @@ function CoverMenu:updateItems(select_number)
title_align = orig_title_align,
buttons = orig_buttons,
}
-- Fudge the "Reset settings" button callback to also trash the cover_info_cache
local button = self.file_dialog.button_table:getButtonById("reset_settings")
local orig_purge_callback = button.callback
button.callback = function()
-- Wipe the cache
if self.cover_info_cache and self.cover_info_cache[file] then
self.cover_info_cache[file] = nil
end
-- And then purge the sidecar folder as expected
orig_purge_callback()
end
-- Replace the "Book information" button callback to use directly our bookinfo
button = self.file_dialog.button_table:getButtonById("book_information")
button.callback = function()
FileManagerBookInfo:show(file, bookinfo)
UIManager:close(self.file_dialog)
end
UIManager:show(self.file_dialog)
return true
end

Loading…
Cancel
Save