ReaderZooming: Deal with some more fallout of the new zoom modes (#7728)

* Namely, ensure zoom_mode is consistent with genus & type *both ways*. (I only dealt with the "no zoom_mode" case in my original fixup).
Because documents with settings dating back from before the new zoom modes had "old" zoom_mode settings mixed with "new" genus/type defaults that didn't agree with each other.
It lead to super-confusing ConfigDialog behavior, because ConfigDialog was in fact not reflecting the reality.
(As the source of truth is actually `zoom_mode`).

* There was a snafu in manual mode, because of the extremely weird way prefixes are handled by Configurable/ReaderConfig/DocSettings/ConfigDialog.
So, make sure we only have a *single* zoom_factor, and that it's updated and saved properly under the right name everywhere.

Fixes inconsistencies between first swapping to manual mode, and what the ConfigDialog said/did (because again: possibly a lie), vs., re-opening the same document, which would magically use *different* settings, closer to what was expected (but still broken because of the prefix mismatch and a disagreement on defaults between the two variants).

Fallout from #6885
This commit is contained in:
NiLuJe
2021-05-22 03:28:52 +02:00
committed by GitHub
parent fdb69e0eee
commit c05b1a4ee4
4 changed files with 91 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ local lfs = require("libs/libkoreader-lfs")
local logger = require("logger")
-- Date at which the last migration snippet was added
local CURRENT_MIGRATION_DATE = 20210518
local CURRENT_MIGRATION_DATE = 20210521
-- Retrieve the date of the previous migration, if any
local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0)
@@ -234,5 +234,18 @@ if last_migration_date < 20210518 then
G_reader_settings:saveSetting("footer", settings)
end
-- 20210521, ReaderZooming, zoom_factor -> kopt_zoom_factor, https://github.com/koreader/koreader/pull/7728
if last_migration_date < 20210521 then
logger.info("Performing one-time migration for 20210521")
-- ReaderZooming:init has the same logic for individual DocSettings in onReadSettings
if G_reader_settings:has("zoom_factor") and G_reader_settings:hasNot("kopt_zoom_factor") then
G_reader_settings:saveSetting("kopt_zoom_factor", G_reader_settings:readSetting("zoom_factor"))
G_reader_settings:delSetting("zoom_factor")
elseif G_reader_settings:has("zoom_factor") and G_reader_settings:has("kopt_zoom_factor") then
G_reader_settings:delSetting("zoom_factor")
end
end
-- We're done, store the current migration date
G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE)