mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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).
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user