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).
reviewable/pr11764/r1
poire-z 4 weeks ago
parent 7d94562602
commit 03d16270d9

@ -2622,6 +2622,13 @@ function ReaderStatistics:onPageUpdate(pageno)
return return
end 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 ;) -- We only care about *actual* page turns ;)
if self.curr_page == pageno then if self.curr_page == pageno then
return return
@ -2773,6 +2780,11 @@ function ReaderStatistics:onReadingResumed()
if data_tuple then if data_tuple then
data_tuple[1] = data_tuple[1] + pause_duration data_tuple[1] = data_tuple[1] + pause_duration
end 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
end end
self._reading_paused_ts = nil self._reading_paused_ts = nil

Loading…
Cancel
Save