mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1797 from chrox/chrox-master
fix occationally stats being cleared
This commit is contained in:
@@ -405,10 +405,14 @@ function ReaderStatistics:onPageUpdate(pageno)
|
||||
self.current_period = self.current_period + diff_time
|
||||
self.data.total_time_in_sec = self.data.total_time_in_sec + diff_time
|
||||
self.data.performance_in_pages[curr_time.sec] = pageno
|
||||
-- we cannot save stats each time this is a page update event,
|
||||
-- because the self.data may not even be initialized when such a event
|
||||
-- comes, which will render a blank stats written into doc settings
|
||||
-- and all previous stats are totally wiped out.
|
||||
self.ui.doc_settings:saveSetting("stats", self.data)
|
||||
end
|
||||
|
||||
self.last_time = curr_time
|
||||
self.ui.doc_settings:saveSetting("stats", self.data)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -486,6 +490,7 @@ function ReaderStatistics:saveSettings(fields)
|
||||
end
|
||||
|
||||
function ReaderStatistics:onReadSettings(config)
|
||||
-- delay initialization for accurate total pages count of the doc
|
||||
UIManager:scheduleIn(0.1, function() self:initData(config) end)
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ describe("Readerfooter module", function()
|
||||
readerui.view.footer.settings.all_at_once = true
|
||||
readerui.view.footer:updateFooterPage()
|
||||
timeinfo = readerui.view.footer:getTimeInfo()
|
||||
assert.are.same('B:0% | '..timeinfo..' | 1 / 1 | => 0 | R:100% | TB: 00:00 | TC: 00:00',
|
||||
-- stats has not been initialized here, so we get na TB and TC
|
||||
assert.are.same('B:0% | '..timeinfo..' | 1 / 1 | => 0 | R:100% | TB: na | TC: na',
|
||||
readerui.view.footer.progress_text.text)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user