Wallabag remove from history setting (#6048)

Solves: #5045
reviewable/pr6059/r2^2
mwoz123 4 years ago committed by GitHub
parent ba4e175ee6
commit 0b52fe9771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,10 @@ local Math = {}
local band = bit.band
function Math.roundPercent(percent)
return math.floor(percent * 10000) / 10000
end
function Math.roundAwayFromZero(num)
if num > 0 then
return math.ceil(num)

@ -47,10 +47,6 @@ local SYNC_STRATEGY = {
DEFAULT_BACKWARD = 3,
}
local function roundPercent(percent)
return math.floor(percent * 10000) / 10000
end
local function showSyncedMessage()
UIManager:show(InfoMessage:new{
text = _("Progress has been synchronized."),
@ -446,9 +442,9 @@ end
function KOSync:getLastPercent()
if self.ui.document.info.has_pages then
return roundPercent(self.ui.paging:getLastPercent())
return Math.roundPercent(self.ui.paging:getLastPercent())
else
return roundPercent(self.ui.rolling:getLastPercent())
return Math.roundPercent(self.ui.rolling:getLastPercent())
end
end

@ -12,8 +12,10 @@ local InfoMessage = require("ui/widget/infomessage")
local InputDialog = require("ui/widget/inputdialog")
local JSON = require("json")
local LuaSettings = require("frontend/luasettings")
local Math = require("optmath")
local MultiInputDialog = require("ui/widget/multiinputdialog")
local NetworkMgr = require("ui/network/manager")
local ReadHistory = require("readhistory")
local UIManager = require("ui/uimanager")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local filemanagerutil = require("apps/filemanager/filemanagerutil")
@ -81,6 +83,7 @@ function Wallabag:init()
if self.wb_settings.data.wallabag.articles_per_sync ~= nil then
self.articles_per_sync = self.wb_settings.data.wallabag.articles_per_sync
end
self.remove_finished_from_history = self.wb_settings.data.wallabag.remove_finished_from_history or false
-- workaround for dateparser only available if newsdownloader is active
self.is_dateparser_available = false
@ -238,6 +241,17 @@ function Wallabag:addToMainMenu(menu_items)
self:saveSettings()
end,
},
{
text = _("Remove finished articles from history"),
keep_menu_open = true,
checked_func = function()
return self.remove_finished_from_history or false
end,
callback = function()
self.remove_finished_from_history = not self.remove_finished_from_history
self:saveSettings()
end,
},
{
text = _("Help"),
keep_menu_open = true,
@ -965,7 +979,8 @@ function Wallabag:saveSettings()
is_archiving_deleted = self.is_archiving_deleted,
is_auto_delete = self.is_auto_delete,
is_sync_remote_delete = self.is_sync_remote_delete,
articles_per_sync = self.articles_per_sync
articles_per_sync = self.articles_per_sync,
remove_finished_from_history = self.remove_finished_from_history,
}
self.wb_settings:saveSetting("wallabag", tempsettings)
self.wb_settings:flush()
@ -1019,4 +1034,22 @@ function Wallabag:onSynchronizeWallabag()
return true
end
function Wallabag:getLastPercent()
if self.ui.document.info.has_pages then
return Math.roundPercent(self.ui.paging:getLastPercent())
else
return Math.roundPercent(self.ui.rolling:getLastPercent())
end
end
function Wallabag:onCloseDocument()
if self.remove_finished_from_history then
local document_full_path = self.ui.document.file
if document_full_path and self.directory and self:getLastPercent() == 1 and self.directory == string.sub(document_full_path, 1, string.len(self.directory)) then
ReadHistory:removeItemByPath(document_full_path)
end
end
end
return Wallabag

Loading…
Cancel
Save