AutoStandby: schedule next standby on init (#12815)

This commit is contained in:
Sébastien Maillard
2024-12-02 22:32:16 +01:00
committed by GitHub
parent 8297d17e54
commit 46b0ec6aa8

View File

@@ -42,10 +42,17 @@ function AutoStandby:init()
UIManager.event_hook:registerWidget("InputEvent", self)
self.ui.menu:registerToMainMenu(self)
-- Schedule the next standby on plugin init, either:
-- 1. When KOReader starts -> to prevent the device from instantly going into standby
-- 2. During a transition -> since the standby scheduled following the input event leading to the transition has been unscheduled
-- to avoid going into standby during the transition, re-schedule the next standby
self:_scheduleNext(os.time(), self.settings.data)
end
function AutoStandby:onCloseWidget()
logger.dbg("AutoStandby:onCloseWidget() instance=", tostring(self))
-- Unschedule the next standby to avoid going into standby during a transition
UIManager:unschedule(AutoStandby.allow)
end
@@ -79,6 +86,12 @@ function AutoStandby:onInputEvent()
return
end
self:_scheduleNext(t, config)
end
-- Schedule the next standby for when it's actually due
function AutoStandby:_scheduleNext(t, config)
-- Nuke past timer as we'll reschedule the allow (or not)
UIManager:unschedule(AutoStandby.allow)