From 03d16270d98046b8d8d9872d7d672d86ed4d6ebe Mon Sep 17 00:00:00 2001 From: poire-z Date: Sun, 5 May 2024 20:59:15 +0200 Subject: [PATCH] Statistics: handle correctly page change when reading paused As currently we only handle ReadingPaused/Resumed on suspend and resume, no page change should happen while paused, so there is no current issue to fix. But let's get ready for other use cases (which may be brought in by user patches, ie. pausing while the SkimWidget is displayed, and obviously triggers page changes). --- plugins/statistics.koplugin/main.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 31a27de0c..c3f003f45 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -2622,6 +2622,13 @@ function ReaderStatistics:onPageUpdate(pageno) return end + if self._reading_paused_ts then + -- Reading paused: don't update stats, but remember the current + -- page for when reading resumed. + self._reading_paused_curr_page = pageno + return + end + -- We only care about *actual* page turns ;) if self.curr_page == pageno then return @@ -2773,6 +2780,11 @@ function ReaderStatistics:onReadingResumed() if data_tuple then data_tuple[1] = data_tuple[1] + pause_duration end + if self._reading_paused_curr_page and self._reading_paused_curr_page ~= self.curr_page then + self._reading_paused_ts = nil + self:onPageUpdate(self._reading_paused_curr_page) + self._reading_paused_curr_page = nil + end end end self._reading_paused_ts = nil