Skip to content

Commit b8e88d6

Browse files
committed
Respect hidden footer on document reopen
1 parent 40edca0 commit b8e88d6

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

main.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ function StatusStats:onReaderReady()
8484
end
8585
if self.settings.show_value_in_footer then
8686
self:addAdditionalFooterContent()
87-
self:ensureFooterModeShowsPluginContent()
87+
if not self:isFooterHidden() then
88+
self:ensureFooterModeShowsPluginContent()
89+
end
8890
end
8991
self:startTicker()
9092
self:refreshStatusBars()
@@ -288,6 +290,14 @@ function StatusStats:getFooterModeName()
288290
return footer.mode_index[footer.mode] or tostring(footer.mode)
289291
end
290292

293+
function StatusStats:isFooterHidden()
294+
local footer = self.ui and self.ui.view and self.ui.view.footer
295+
if not (footer and footer.mode and footer.mode_list and footer.mode_list.off) then
296+
return false
297+
end
298+
return footer.mode == footer.mode_list.off
299+
end
300+
291301
function StatusStats:ensureFooterModeShowsPluginContent()
292302
local footer = self.ui and self.ui.view and self.ui.view.footer
293303
if not (footer and footer.settings) then

tests/statusstats_spec.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,30 @@ assertEquals(startup_footer_plugin.ui.view.footer.mode, "additional_content", "r
482482
assertEquals(startup_footer_plugin.ui.view.footer.add_calls, 1, "reader ready should add footer content once")
483483
assertEquals(startup_footer_plugin.ui.view.footer.refresh_calls, 1, "reader ready should refresh the footer after restoring visibility")
484484

485+
local hidden_footer_plugin = newPlugin({
486+
show_value_in_footer = true,
487+
}, {
488+
session = {
489+
time = 0,
490+
pages = 0,
491+
},
492+
today = {
493+
time = 0,
494+
pages = 0,
495+
},
496+
})
497+
498+
hidden_footer_plugin.ui.view.footer.mode_list.off = "off"
499+
hidden_footer_plugin.ui.view.footer.mode_index.off = "off"
500+
hidden_footer_plugin.ui.view.footer.mode = "off"
501+
hidden_footer_plugin.ui.view.footer.settings.additional_content = false
502+
503+
hidden_footer_plugin:onReaderReady()
504+
505+
assertEquals(hidden_footer_plugin.ui.view.footer.mode, "off", "reader ready should not force a hidden footer visible")
506+
assertTrue(not hidden_footer_plugin.ui.view.footer.settings.additional_content, "reader ready should respect hidden footer additional content state")
507+
assertEquals(hidden_footer_plugin.ui.view.footer.add_calls, 1, "reader ready should still register footer content while hidden")
508+
485509
local restore_footer_plugin = newPlugin({
486510
show_value_in_footer = false,
487511
}, {

0 commit comments

Comments
 (0)