2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Merge pull request #1754 from houqp/fixstats

fix(ReaderFooter:getDataFromStatistics): return na if book has no stats history
This commit is contained in:
Huang Xin 2015-12-23 22:54:54 +08:00
commit bbde70fb3d
2 changed files with 9 additions and 2 deletions

View File

@ -242,11 +242,13 @@ end
function ReaderFooter:getDataFromStatistics(title, pages)
local statistics_data = self.ui.doc_settings:readSetting("stats")
local sec = 'na'
if statistics_data and statistics_data.performance_in_pages then
local read_pages = util.tablelength(statistics_data.performance_in_pages)
local average_time_per_page = statistics_data.total_time_in_sec / read_pages
return title .. util.secondsToClock(pages * average_time_per_page, true)
sec = util.secondsToClock(pages * average_time_per_page, true)
end
return title .. sec
end

View File

@ -327,7 +327,12 @@ function ReaderUI:showReader(file)
local co = coroutine.create(function()
self:doShowReader(file)
end)
coroutine.resume(co)
local ok, err = coroutine.resume(co)
if err ~= nil then
print '[!] doShowReader coroutine crashed:'
print(debug.traceback(co, err, 1))
UIManager._running = false
end
end)
end