mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Statistics: Properly initialize default settings. (#7471)
* Statistics: Properly initialize default settings. Regression since #7371 Fix #7470
This commit is contained in:
@@ -58,12 +58,6 @@ local STATISTICS_SQL_BOOK_TOTALS_QUERY = [[
|
||||
|
||||
local ReaderStatistics = Widget:extend{
|
||||
name = "statistics",
|
||||
page_min_read_sec = DEFAULT_MIN_READ_SEC,
|
||||
page_max_read_sec = DEFAULT_MAX_READ_SEC,
|
||||
calendar_start_day_of_week = DEFAULT_CALENDAR_START_DAY_OF_WEEK,
|
||||
calendar_nb_book_spans = DEFAULT_CALENDAR_NB_BOOK_SPANS,
|
||||
calendar_show_histogram = true,
|
||||
calendar_browse_future_months = false,
|
||||
start_current_period = 0,
|
||||
curr_page = 0,
|
||||
id_curr_book = nil,
|
||||
@@ -137,8 +131,25 @@ function ReaderStatistics:init()
|
||||
end
|
||||
self.start_current_period = os.time()
|
||||
self:resetVolatileStats()
|
||||
self.settings = G_reader_settings:readSetting("statistics", {})
|
||||
self.settings.is_enabled = not (self.settings.is_enabled == false)
|
||||
|
||||
local default_settings = {
|
||||
min_sec = DEFAULT_MIN_READ_SEC,
|
||||
max_sec = DEFAULT_MAX_READ_SEC,
|
||||
is_enabled = true,
|
||||
convert_to_db = nil,
|
||||
calendar_start_day_of_week = DEFAULT_CALENDAR_START_DAY_OF_WEEK,
|
||||
calendar_nb_book_spans = DEFAULT_CALENDAR_NB_BOOK_SPANS,
|
||||
calendar_show_histogram = true,
|
||||
calendar_browse_future_months = false,
|
||||
}
|
||||
self.settings = G_reader_settings:readSetting("statistics", default_settings)
|
||||
-- Handle a snafu in 2021.03 that could lead to an empty settings table on fresh installs.
|
||||
for k, v in pairs(default_settings) do
|
||||
if self.settings[k] == nil then
|
||||
self.settings[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
self:checkInitDatabase()
|
||||
BookStatusWidget.getStats = function()
|
||||
|
||||
Reference in New Issue
Block a user