mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
LuaSettings: Add a method to initialize a setting properly (#7371)
* LuaSettings/DocSettings: Updated readSetting API to allow proper initialization to default. Use it to initialize tables, e.g., fixing corner-cases in readerFooter that could prevent settings from being saved. (Fixes an issue reported on Gitter). * LuaSettings/DocSettings: Add simpler API than the the flip* ones to toggle boolean settings. * Update LuaSettings/DocSettigns usage throughout the codebase to use the dedicated boolean methods wher appropriate, and clean up some of the more mind-bending uses. * FileChooser: Implement an extended default exclusion list (fix #2360) * ScreenSaver: Refactor to avoid the pile of kludges this was threatening to become. Code should be easier to follow and use, and fallbacks now behave as expected (fix #4418).
This commit is contained in:
@@ -72,10 +72,7 @@ function DocumentRegistry:hasProvider(file, mimetype)
|
||||
end
|
||||
local DocSettings = require("docsettings")
|
||||
if DocSettings:hasSidecarFile(file) then
|
||||
local doc_settings_provider = DocSettings:open(file):readSetting("provider")
|
||||
if doc_settings_provider then
|
||||
return true
|
||||
end
|
||||
return DocSettings:open(file):has("provider")
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -134,7 +131,8 @@ function DocumentRegistry:getProviders(file)
|
||||
local added = false
|
||||
local suffix = string.sub(file, -string.len(provider.extension) - 1)
|
||||
if string.lower(suffix) == "."..provider.extension then
|
||||
for i, prov_prev in ipairs(providers) do
|
||||
for i = #providers, 1, -1 do
|
||||
local prov_prev = providers[i]
|
||||
if prov_prev.provider == provider.provider then
|
||||
if prov_prev.weight >= provider.weight then
|
||||
added = true
|
||||
@@ -143,7 +141,7 @@ function DocumentRegistry:getProviders(file)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- if extension == provider.extension then
|
||||
-- if extension == provider.extension then
|
||||
-- stick highest weighted provider at the front
|
||||
if not added and #providers >= 1 and provider.weight > providers[1].weight then
|
||||
table.insert(providers, 1, provider)
|
||||
|
||||
Reference in New Issue
Block a user