5924 nd force skip imasges dl#6003
Conversation
| local file_extension = ".epub" | ||
| local news_download_dir_name = "news" | ||
| local news_download_dir_path, feed_config_path | ||
| local global_exlude_images_config_name = 'global_exlude_images_config_name'; |
There was a problem hiding this comment.
| local global_exlude_images_config_name = 'global_exlude_images_config_name'; | |
| local global_exlude_images_config_name = "global_exlude_images_config_name" |
| callback = function() self:removeNewsButKeepFeedConfig() end, | ||
| }, | ||
| { | ||
| text = _("Global skip images download"), |
There was a problem hiding this comment.
If you reverse the logic you could just call it:
| text = _("Global skip images download"), | |
| text = _("Download images"), |
Or maybe:
| text = _("Global skip images download"), | |
| text = _("Download images (default)"), |
| local news_download_dir_name = "news" | ||
| local news_download_dir_path, feed_config_path | ||
| local global_exlude_images_config_name = 'global_exlude_images_config_name'; | ||
| local global_skip_images_download_config_name = 'global_skip_images_download_config_name'; |
There was a problem hiding this comment.
| local global_skip_images_download_config_name = 'global_skip_images_download_config_name'; | |
| local global_skip_images_download_config_name = "global_skip_images_download_config_name" |
| callback = function() | ||
| local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file)) | ||
| local skip = news_downloader_settings:readSetting(global_skip_images_download_config_name) or false; | ||
| logger.warn('NewsDownloader: global_skip_images_download', skip) |
There was a problem hiding this comment.
| logger.warn('NewsDownloader: global_skip_images_download', skip) | |
| logger.debug("NewsDownloader: global_skip_images_download", skip) |
| local news_download_dir_name = "news" | ||
| local news_download_dir_path, feed_config_path | ||
| local global_skip_images_download_config_name = 'global_skip_images_download_config_name'; | ||
| local force_skip_images_download_config_name = 'force_skip_images_download_config_name'; |
There was a problem hiding this comment.
| local force_skip_images_download_config_name = 'force_skip_images_download_config_name'; | |
| local force_skip_images_download_config_name = "force_skip_images_download_config_name" |
| }, | ||
| { | ||
| text = _("Force skip images download toggle"), | ||
| text = _("Toogle: force skip images download"), |
There was a problem hiding this comment.
Typo, but I'm not entirely sure what the text means. I suspect that "toggle" shouldn't be there since it'd already be visually in the checkbox.
| text = _("Toogle: force skip images download"), | |
| text = _("Toggle: force skip images download"), |
| callback = function() | ||
| local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file)) | ||
| local skip = news_downloader_settings:readSetting(force_skip_images_download_config_name) or false; | ||
| logger.warn('NewsDownloader: previous force_skip_images_download: ', skip) |
There was a problem hiding this comment.
| logger.warn('NewsDownloader: previous force_skip_images_download: ', skip) | |
| logger.info("NewsDownloader: previous force_skip_images_download: ", skip) |
There was a problem hiding this comment.
The hole idea was to make it a quick way to sometimes disable images (e.g. slow wifi, no time for downloading all data, use smaller amount of wifi in case of being currently connected to limited transfer wifi etc).
I didn't want to make it a replacement for" include_images " which can be set for each rss/atom source independly.
And the above screenshot looks this way for me that 's why I wanted to mark it as "skip" / "temporally" etc..
There was a problem hiding this comment.
Btw I like the idea with checkbox (and would like to have it) but remembered that moving "lua Settings open" to lazy load was because there was a need/request to speed up menu.
That's why I didn't use it..
There was a problem hiding this comment.
Maybe you're thinking of something wifi-related? It already says self:lazyInitialization() in addToMainMenu so regardless how slow that may or may not be, the cost is incurred.
koreader/plugins/newsdownloader.koplugin/main.lua
Lines 72 to 73 in 0b89862
There was a problem hiding this comment.
Ok, how about checkbox + name that indicates enabling won't cause automatically downloading images from all sources (as it still has to be enabled in feed_config.lua)?
There was a problem hiding this comment.
I have no problem with Never download images.
There was a problem hiding this comment.
Ok checkbox + "never download images " is much safer will do so.
BTW I'm not familiar with recent git changes.
Although I haven't touch the majority of the PR request changes they are marked as 'outdated'.
Do I need to change them or you somehow patched it?
There was a problem hiding this comment.
No, that just means I thought you submitted a PR with 4 distinct commits which I mistakenly reviewed independently.
| callback = function() self:removeNewsButKeepFeedConfig() end, | ||
| }, | ||
| { | ||
| text = _("Force skip images download"), |
There was a problem hiding this comment.
@NiLuJe Do you have any thoughts? I'm not overly fond of this string. (Setting aside that Force skip image download would be the more idiomatic form of it.)
There was a problem hiding this comment.
Probably applies to a bunch of similar strings up the chain, then ;).
(and/or variable names if someone wants to go the extra mile and it makes sense re: the rest of the code).
There was a problem hiding this comment.
Yes, my thoughts exactly (also see here because I mistakenly thought the commits were distinct units). :-)
| text = _("Force skip images download"), | |
| text = _("Never download images"), |
There was a problem hiding this comment.
And yes, the variable name would also be much clearer as never_download_images
There was a problem hiding this comment.
Guys IMHO "never" means something that will burn down function (or even hardware? (if I would have been non-tech) :p) responsible for downloading images.
I would NEVER click that (if I didn't write that function):p
I'm serious.
"never" for me means "forever"
This is "temporarily" quick toggle disable you can quickly reverse it and its gets back to normal downloading images (if set so in config file) not forever!
Please rethink once again you request
There was a problem hiding this comment.
How about " temporary skip images"?
There was a problem hiding this comment.
That's because I overlooked that you made it scary, and it also explains the weird popup. ;-)
Should be like this instead:
diff --git a/plugins/newsdownloader.koplugin/main.lua b/plugins/newsdownloader.koplugin/main.lua
index 5f3921b1..debbaa64 100644
--- a/plugins/newsdownloader.koplugin/main.lua
+++ b/plugins/newsdownloader.koplugin/main.lua
@@ -107,18 +107,20 @@ function NewsDownloader:addToMainMenu(menu_items)
callback = function() self:removeNewsButKeepFeedConfig() end,
},
{
- text = _("Force skip images download"),
+ text = _("Never download images"),
keep_menu_open = true,
+ checked_func = function()
+ -- Not sure this should all be quite this local all over the file ;-)
+ local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
+ local skip = news_downloader_settings:readSetting(force_skip_images_download_config_name)
+ return skip
+ end,
callback = function()
local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
local skip = news_downloader_settings:readSetting(force_skip_images_download_config_name) or false;
logger.warn('NewsDownloader: previous force_skip_images_download: ', skip)
news_downloader_settings:saveSetting(force_skip_images_download_config_name, not skip)
news_downloader_settings:flush()
- UIManager:show(InfoMessage:new{
- text = T(_("Force skip images download set to %1"),
- string.format("%s", not skip))
- })
end,
},
{| keep_menu_open = true, | ||
| callback = function() | ||
| local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file)) | ||
| local skip = news_downloader_settings:readSetting(force_skip_images_download_config_name) or false; |
There was a problem hiding this comment.
| local skip = news_downloader_settings:readSetting(force_skip_images_download_config_name) or false; | |
| local skip = news_downloader_settings:readSetting(force_skip_images_download_config_name) or false |
|
changes done. |
| text = _("Never download images"), | ||
| keep_menu_open = true, | ||
| checked_func = function() | ||
| local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file)) |
There was a problem hiding this comment.
To be clear, I meant that the cost wouldn't be incurred if you didn't keep the settings excessively local. In this case there is an extra cost — not one that would be noticeable of course, but surely it should be more measurable than whatever profit you could possibly get out of that never_download_images_config_name thing.
I mean something like this:
diff --git a/plugins/newsdownloader.koplugin/main.lua b/plugins/newsdownloader.koplugin/main.lua
index 0a141c15..7695fcd3 100644
--- a/plugins/newsdownloader.koplugin/main.lua
+++ b/plugins/newsdownloader.koplugin/main.lua
@@ -25,6 +25,7 @@ local initialized = false
local wifi_enabled_before_action = true
local feed_config_file_name = "feed_config.lua"
local news_downloader_config_file = "news_downloader_settings.lua"
+local news_downloader_settings
local config_key_custom_dl_dir = "custom_dl_dir"
local file_extension = ".epub"
local news_download_dir_name = "news"
@@ -110,11 +111,9 @@ function NewsDownloader:addToMainMenu(menu_items)
text = _("Never download images"),
keep_menu_open = true,
checked_func = function()
- local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
return news_downloader_settings:readSetting(never_download_images_config_name)
end,
callback = function()
- local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
local never_download_images = news_downloader_settings:readSetting(never_download_images_config_name) or false
logger.info("NewsDownloader: previous never_download_images: ", never_download_images)
news_downloader_settings:saveSetting(never_download_images_config_name, not never_download_images)
@@ -153,7 +152,7 @@ end
function NewsDownloader:lazyInitialization()
if not initialized then
logger.dbg("NewsDownloader: obtaining news folder")
- local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
+ news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
if news_downloader_settings:has(config_key_custom_dl_dir) then
news_download_dir_path = news_downloader_settings:readSetting(config_key_custom_dl_dir)
else
@@ -191,7 +190,6 @@ function NewsDownloader:loadConfigAndProcessFeeds()
return
end
- local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
local never_download_images = news_downloader_settings:readSetting(never_download_images_config_name) or false
local unsupported_feeds_urls = {}
@@ -409,7 +407,6 @@ function NewsDownloader:setCustomDownloadDirectory()
require("ui/downloadmgr"):new{
onConfirm = function(path)
logger.dbg("NewsDownloader: set download directory to: ", path)
- local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file))
news_downloader_settings:saveSetting(config_key_custom_dl_dir, ("%s/"):format(path))
news_downloader_settings:flush()
More for ease of reading than performance really, that local news_downloader_settings = LuaSettings:open(("%s/%s"):format(DataStorage:getSettingsDir(), news_downloader_config_file)) is quite distracting.
| local file_extension = ".epub" | ||
| local news_download_dir_name = "news" | ||
| local news_download_dir_path, feed_config_path | ||
| local never_download_images_config_name = "never_download_images_config_name" |
There was a problem hiding this comment.
I find this unnecessarily complex. I don't follow the reasoning behind not to just using readSetting("never_download_images"), but setting that aside:
| local never_download_images_config_name = "never_download_images_config_name" | |
| local never_download_images_config_name = "never_download_images" |
|
done |



Solves: #5924
This change is