2016-04-18 22:38:14 +00:00
|
|
|
local DataStorage = require("datastorage")
|
|
|
|
local DocSettings = require("docsettings")
|
2022-11-17 04:53:35 +00:00
|
|
|
local datetime = require("datetime")
|
2016-04-18 22:38:14 +00:00
|
|
|
local dump = require("dump")
|
2019-12-10 22:00:08 +00:00
|
|
|
local ffiutil = require("ffi/util")
|
2020-08-29 16:25:36 +00:00
|
|
|
local util = require("util")
|
2019-12-10 22:00:08 +00:00
|
|
|
local joinPath = ffiutil.joinPath
|
2017-07-19 12:56:17 +00:00
|
|
|
local lfs = require("libs/libkoreader-lfs")
|
2019-12-10 22:00:08 +00:00
|
|
|
local realpath = ffiutil.realpath
|
2023-12-10 06:05:34 +00:00
|
|
|
local C_ = require("gettext").pgettext
|
2016-04-18 22:38:14 +00:00
|
|
|
|
|
|
|
local history_file = joinPath(DataStorage:getDataDir(), "history.lua")
|
|
|
|
|
Clarify our OOP semantics across the codebase (#9586)
Basically:
* Use `extend` for class definitions
* Use `new` for object instantiations
That includes some minor code cleanups along the way:
* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
* ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2022-10-06 00:14:48 +00:00
|
|
|
-- This is a singleton
|
2016-04-18 22:38:14 +00:00
|
|
|
local ReadHistory = {
|
|
|
|
hist = {},
|
2017-07-19 12:56:17 +00:00
|
|
|
last_read_time = 0,
|
2016-04-18 22:38:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-22 19:42:41 +00:00
|
|
|
local function getMandatory(date_time)
|
|
|
|
return G_reader_settings:isTrue("history_datetime_short")
|
2023-12-10 06:05:34 +00:00
|
|
|
and os.date(C_("Date string", "%y-%m-%d"), date_time) or datetime.secondsToDateTime(date_time)
|
2023-06-22 19:42:41 +00:00
|
|
|
end
|
|
|
|
|
2016-04-18 22:38:14 +00:00
|
|
|
local function buildEntry(input_time, input_file)
|
2020-08-29 16:25:36 +00:00
|
|
|
local file_path = realpath(input_file) or input_file -- keep orig file path of deleted files
|
2023-03-26 18:11:19 +00:00
|
|
|
local file_exists = lfs.attributes(file_path, "mode") == "file"
|
2016-04-18 22:38:14 +00:00
|
|
|
return {
|
|
|
|
time = input_time,
|
2020-08-29 16:25:36 +00:00
|
|
|
file = file_path,
|
2022-10-25 10:15:59 +00:00
|
|
|
text = input_file:gsub(".*/", ""),
|
2023-03-26 18:11:19 +00:00
|
|
|
dim = not file_exists,
|
2023-06-22 19:42:41 +00:00
|
|
|
mandatory = getMandatory(input_time),
|
2023-03-26 18:11:19 +00:00
|
|
|
select_enabled = file_exists,
|
2016-04-18 22:38:14 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
function ReadHistory:getIndexByFile(item_file)
|
|
|
|
for i, v in ipairs(self.hist) do
|
|
|
|
if item_file == v.file then
|
|
|
|
return i
|
|
|
|
end
|
2016-09-13 03:02:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Returns leftmost index of the entry with item_time using binary search
|
|
|
|
-- (items in history are sorted by time in reverse order).
|
|
|
|
-- If several entries have equal time, search within them by item_file in alphabetical order.
|
|
|
|
-- If there are no entries with item_time, returns insertion index.
|
|
|
|
function ReadHistory:getIndexByTime(item_time, item_file)
|
|
|
|
local hist_nb = #self.hist
|
|
|
|
if hist_nb == 0 then
|
|
|
|
return 1
|
2016-09-13 03:02:48 +00:00
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
if item_time > self.hist[1].time then
|
|
|
|
return 1
|
|
|
|
elseif item_time < self.hist[hist_nb].time then
|
|
|
|
return hist_nb + 1
|
2016-07-19 05:37:57 +00:00
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
local s, e, m, d = 1, hist_nb
|
|
|
|
while s <= e do
|
|
|
|
m = bit.rshift(s + e, 1)
|
|
|
|
if item_time < self.hist[m].time then
|
|
|
|
s, d = m + 1, 1
|
|
|
|
else
|
|
|
|
e, d = m - 1, 0
|
|
|
|
end
|
2017-02-25 21:16:19 +00:00
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
local index = m + d
|
|
|
|
if item_file then
|
|
|
|
while index <= #self.hist
|
|
|
|
and self.hist[index].time == item_time
|
|
|
|
and self.hist[index].file:gsub(".*/", "") < item_file do
|
|
|
|
index = index + 1
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
return index
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Reduces number of history items to the required limit by removing old items.
|
2016-04-18 22:38:14 +00:00
|
|
|
function ReadHistory:_reduce()
|
2022-10-25 10:15:59 +00:00
|
|
|
local history_size = G_reader_settings:readSetting("history_size") or 500
|
|
|
|
while #self.hist > history_size do
|
|
|
|
table.remove(self.hist)
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Saves history table to a file.
|
2016-04-18 22:38:14 +00:00
|
|
|
function ReadHistory:_flush()
|
|
|
|
local content = {}
|
2020-05-29 12:30:39 +00:00
|
|
|
for _, v in ipairs(self.hist) do
|
|
|
|
table.insert(content, {
|
2016-04-18 22:38:14 +00:00
|
|
|
time = v.time,
|
2023-11-10 05:50:39 +00:00
|
|
|
file = v.file,
|
2020-05-29 12:30:39 +00:00
|
|
|
})
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
2023-10-17 04:42:07 +00:00
|
|
|
util.writeToFile(dump(content), history_file, true, true)
|
2023-01-04 00:24:23 +00:00
|
|
|
self:ensureLastFile()
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
|
2017-07-19 12:56:17 +00:00
|
|
|
--- Reads history table from file.
|
|
|
|
-- @treturn boolean true if the history_file has been updated and reloaded.
|
2022-02-17 12:17:21 +00:00
|
|
|
function ReadHistory:_read(force_read)
|
2017-07-19 12:56:17 +00:00
|
|
|
local history_file_modification_time = lfs.attributes(history_file, "modification")
|
2022-10-25 10:15:59 +00:00
|
|
|
if history_file_modification_time == nil then -- no history_file, proceed legacy only
|
|
|
|
return true
|
2017-07-19 12:56:17 +00:00
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
if force_read or (history_file_modification_time > self.last_read_time) then
|
|
|
|
self.last_read_time = history_file_modification_time
|
|
|
|
local ok, data = pcall(dofile, history_file)
|
|
|
|
if ok and data then
|
|
|
|
self.hist = {}
|
|
|
|
for _, v in ipairs(data) do
|
|
|
|
table.insert(self.hist, buildEntry(v.time, v.file))
|
|
|
|
end
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
return true
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-02 06:39:09 +00:00
|
|
|
--- Reads history from legacy history folder and remove it iff empty.
|
|
|
|
-- Legacy history file is deleted when respective book is opened or deleted.
|
2016-04-18 22:38:14 +00:00
|
|
|
function ReadHistory:_readLegacyHistory()
|
|
|
|
local history_dir = DataStorage:getHistoryDir()
|
2023-03-02 06:39:09 +00:00
|
|
|
if not lfs.attributes(history_dir) then return end
|
|
|
|
local history_updated
|
2016-04-18 22:38:14 +00:00
|
|
|
for f in lfs.dir(history_dir) do
|
2023-02-17 06:35:49 +00:00
|
|
|
local legacy_history_file = joinPath(history_dir, f)
|
|
|
|
if lfs.attributes(legacy_history_file, "mode") == "file" then
|
|
|
|
local item_path = DocSettings:getFileFromHistory(f)
|
|
|
|
if item_path then
|
|
|
|
local item_time = lfs.attributes(legacy_history_file, "modification")
|
|
|
|
if self:addItem(item_path, item_time, true) then
|
|
|
|
history_updated = true
|
2016-07-19 05:37:57 +00:00
|
|
|
end
|
|
|
|
end
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
if history_updated then
|
|
|
|
self:_reduce()
|
|
|
|
self:_flush()
|
|
|
|
end
|
2023-03-02 06:39:09 +00:00
|
|
|
os.remove(history_dir)
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
|
2020-05-06 19:11:34 +00:00
|
|
|
function ReadHistory:ensureLastFile()
|
2022-10-25 10:15:59 +00:00
|
|
|
local last_existing_file
|
|
|
|
for _, v in ipairs(self.hist) do
|
2023-11-10 05:50:39 +00:00
|
|
|
if v.select_enabled then
|
2022-10-25 10:15:59 +00:00
|
|
|
last_existing_file = v.file
|
2020-05-06 19:11:34 +00:00
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
G_reader_settings:saveSetting("lastfile", last_existing_file)
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Get last or previous file in history that is not current_file
|
|
|
|
-- (self.ui.document.file, provided as current_file, might have
|
|
|
|
-- been removed from history).
|
2020-05-06 19:11:34 +00:00
|
|
|
function ReadHistory:getPreviousFile(current_file)
|
|
|
|
if not current_file then
|
|
|
|
current_file = G_reader_settings:readSetting("lastfile")
|
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
for _, v in ipairs(self.hist) do
|
2020-05-06 19:11:34 +00:00
|
|
|
-- skip current document and deleted items kept in history
|
2023-11-10 05:50:39 +00:00
|
|
|
if v.file ~= current_file and v.select_enabled then
|
2022-10-25 10:15:59 +00:00
|
|
|
return v.file
|
2020-05-06 19:11:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Used in the BookShortcuts plugin.
|
2022-03-23 22:05:18 +00:00
|
|
|
function ReadHistory:getFileByDirectory(directory, recursive)
|
2021-11-21 19:51:42 +00:00
|
|
|
local real_path = realpath(directory)
|
2022-10-25 10:15:59 +00:00
|
|
|
for _, v in ipairs(self.hist) do
|
|
|
|
local ipath = realpath(ffiutil.dirname(v.file))
|
2022-03-23 22:05:18 +00:00
|
|
|
if ipath == real_path or (recursive and util.stringStartsWith(ipath, real_path)) then
|
2022-10-25 10:15:59 +00:00
|
|
|
return v.file
|
2021-11-21 19:51:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-13 04:54:35 +00:00
|
|
|
--- Updates the history list after renaming/moving a file.
|
2023-12-10 06:05:34 +00:00
|
|
|
function ReadHistory:updateItem(file, new_filepath)
|
|
|
|
local index = self:getIndexByFile(file)
|
2022-10-25 10:15:59 +00:00
|
|
|
if index then
|
2023-12-10 06:05:34 +00:00
|
|
|
local item = self.hist[index]
|
|
|
|
item.file = new_filepath
|
|
|
|
item.text = new_filepath:gsub(".*/", "")
|
|
|
|
self:_flush()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReadHistory:updateItems(files, new_path) -- files = { filepath = true, }
|
|
|
|
local history_updated
|
|
|
|
for file in pairs(files) do
|
|
|
|
local index = self:getIndexByFile(file)
|
|
|
|
if index then
|
|
|
|
local item = self.hist[index]
|
|
|
|
item.file = new_path .. "/" .. item.text
|
|
|
|
history_updated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if history_updated then
|
2022-10-25 10:15:59 +00:00
|
|
|
self:_flush()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-13 04:54:35 +00:00
|
|
|
--- Updates the history list after renaming/moving a folder.
|
|
|
|
function ReadHistory:updateItemsByPath(old_path, new_path)
|
2023-12-10 06:05:34 +00:00
|
|
|
local len = #old_path
|
2023-10-13 04:54:35 +00:00
|
|
|
local history_updated
|
|
|
|
for i, v in ipairs(self.hist) do
|
2023-12-10 06:05:34 +00:00
|
|
|
if v.file:sub(1, len) == old_path then
|
|
|
|
self.hist[i].file = new_path .. v.file:sub(len + 1)
|
2023-10-13 04:54:35 +00:00
|
|
|
history_updated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if history_updated then
|
|
|
|
self:_flush()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Updates the history list after deleting a file.
|
2023-11-10 05:50:39 +00:00
|
|
|
function ReadHistory:fileDeleted(path_or_index)
|
|
|
|
local index
|
|
|
|
local is_single = type(path_or_index) == "string"
|
|
|
|
if is_single then -- deleting single file, path passed
|
|
|
|
index = self:getIndexByFile(path_or_index)
|
|
|
|
else -- deleting folder, index passed
|
|
|
|
index = path_or_index
|
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
if index then
|
|
|
|
if G_reader_settings:isTrue("autoremove_deleted_items_from_history") then
|
2023-11-10 05:50:39 +00:00
|
|
|
self:removeItem(self.hist[index], index, not is_single) -- flush immediately when deleting single file only
|
2022-10-25 10:15:59 +00:00
|
|
|
else
|
|
|
|
self.hist[index].dim = true
|
2023-02-23 17:23:30 +00:00
|
|
|
self.hist[index].select_enabled = false
|
2023-11-10 05:50:39 +00:00
|
|
|
if is_single then
|
|
|
|
self:ensureLastFile()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Updates the history list after deleting a folder.
|
|
|
|
function ReadHistory:folderDeleted(path)
|
|
|
|
local history_updated
|
|
|
|
for i = #self.hist, 1, -1 do
|
|
|
|
local file = self.hist[i].file
|
|
|
|
if util.stringStartsWith(file, path) then
|
|
|
|
self:fileDeleted(i)
|
|
|
|
history_updated = true
|
|
|
|
DocSettings.updateLocation(file) -- remove sdr if not in book location
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if history_updated then
|
|
|
|
if G_reader_settings:isTrue("autoremove_deleted_items_from_history") then
|
|
|
|
self:_flush()
|
|
|
|
else
|
2022-10-25 10:15:59 +00:00
|
|
|
self:ensureLastFile()
|
2020-05-06 19:11:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-12-10 06:05:34 +00:00
|
|
|
function ReadHistory:removeItems(files) -- files = { filepath = true, }
|
|
|
|
local history_updated
|
|
|
|
for file in pairs(files) do
|
|
|
|
local index = self:getIndexByFile(file)
|
|
|
|
if index then
|
|
|
|
self:fileDeleted(index)
|
|
|
|
history_updated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if history_updated then
|
|
|
|
if G_reader_settings:isTrue("autoremove_deleted_items_from_history") then
|
|
|
|
self:_flush()
|
|
|
|
else
|
|
|
|
self:ensureLastFile()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Removes the history item if the document settings has been reset.
|
2020-05-06 19:11:34 +00:00
|
|
|
function ReadHistory:fileSettingsPurged(path)
|
2021-03-06 21:44:18 +00:00
|
|
|
if G_reader_settings:isTrue("autoremove_deleted_items_from_history") then
|
2020-05-06 19:11:34 +00:00
|
|
|
self:removeItemByPath(path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Checks the history list for deleted files and removes history items respectively.
|
2017-02-25 18:22:04 +00:00
|
|
|
function ReadHistory:clearMissing()
|
2022-10-25 10:15:59 +00:00
|
|
|
local history_updated
|
2023-03-28 17:04:40 +00:00
|
|
|
for i = #self.hist, 1, -1 do
|
|
|
|
local file = self.hist[i].file
|
|
|
|
if file == nil or lfs.attributes(file, "mode") ~= "file" then
|
|
|
|
self:removeItem(self.hist[i], i, true) -- no flush
|
2022-10-25 10:15:59 +00:00
|
|
|
history_updated = true
|
2017-02-25 18:22:04 +00:00
|
|
|
end
|
|
|
|
end
|
2022-10-25 10:15:59 +00:00
|
|
|
if history_updated then
|
|
|
|
self:_flush()
|
2017-02-25 21:16:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
function ReadHistory:removeItemByPath(path)
|
|
|
|
local index = self:getIndexByFile(path)
|
|
|
|
if index then
|
|
|
|
self:removeItem(self.hist[index], index)
|
2020-05-06 19:11:34 +00:00
|
|
|
end
|
2018-01-16 17:20:25 +00:00
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
function ReadHistory:removeItem(item, idx, no_flush)
|
|
|
|
local index = idx or self:getIndexByTime(item.time, item.file:gsub(".*/", ""))
|
|
|
|
table.remove(self.hist, index)
|
2016-04-18 22:38:14 +00:00
|
|
|
os.remove(DocSettings:getHistoryPath(item.file))
|
2022-10-25 10:15:59 +00:00
|
|
|
if not no_flush then
|
|
|
|
self:_flush()
|
|
|
|
end
|
2016-04-18 22:38:14 +00:00
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Adds new item (last opened document) to the top of the history list.
|
|
|
|
-- If item time (ts) is passed, add item to the history list at this time position.
|
2023-02-23 17:23:30 +00:00
|
|
|
function ReadHistory:addItem(file, ts, no_flush)
|
2024-02-07 08:35:52 +00:00
|
|
|
file = realpath(file)
|
|
|
|
if not file or (ts and lfs.attributes(file, "mode") ~= "file") then
|
|
|
|
return -- bad legacy item
|
|
|
|
end
|
|
|
|
local index = self:getIndexByFile(file)
|
|
|
|
if ts and index and self.hist[index].time == ts then
|
|
|
|
return -- legacy item already added
|
|
|
|
end
|
|
|
|
local now = ts or os.time()
|
|
|
|
local mtime = lfs.attributes(file, "modification")
|
|
|
|
lfs.touch(file, now, mtime) -- update book access time for sorting by last read date
|
|
|
|
if index == 1 and not ts then -- last book, update access time only
|
|
|
|
self.hist[1].time = now
|
|
|
|
self.hist[1].mandatory = getMandatory(now)
|
|
|
|
else -- old or new book
|
|
|
|
if index then -- old book
|
|
|
|
table.remove(self.hist, index)
|
2022-10-25 10:15:59 +00:00
|
|
|
end
|
2024-02-07 08:35:52 +00:00
|
|
|
index = ts and self:getIndexByTime(ts, file:gsub(".*/", "")) or 1
|
|
|
|
table.insert(self.hist, index, buildEntry(now, file))
|
|
|
|
end
|
|
|
|
if not no_flush then
|
|
|
|
self:_reduce()
|
|
|
|
self:_flush()
|
2017-09-22 16:24:38 +00:00
|
|
|
end
|
2024-02-07 08:35:52 +00:00
|
|
|
return true -- used while adding legacy items
|
2017-09-22 16:24:38 +00:00
|
|
|
end
|
|
|
|
|
2023-02-23 17:23:30 +00:00
|
|
|
--- Updates last book access time on closing the document.
|
|
|
|
function ReadHistory:updateLastBookTime(no_flush)
|
|
|
|
local now = os.time()
|
|
|
|
self.hist[1].time = now
|
2023-06-22 19:42:41 +00:00
|
|
|
self.hist[1].mandatory = getMandatory(now)
|
2023-02-23 17:23:30 +00:00
|
|
|
if not no_flush then
|
|
|
|
self:_flush()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-10 05:50:39 +00:00
|
|
|
function ReadHistory:updateDateTimeString()
|
|
|
|
for _, v in ipairs(self.hist) do
|
|
|
|
v.mandatory = getMandatory(v.time)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-25 10:15:59 +00:00
|
|
|
--- Reloads history from history_file and legacy history folder.
|
2022-02-17 12:17:21 +00:00
|
|
|
function ReadHistory:reload(force_read)
|
|
|
|
if self:_read(force_read) then
|
2017-07-19 12:56:17 +00:00
|
|
|
self:_readLegacyHistory()
|
2022-10-25 10:15:59 +00:00
|
|
|
if G_reader_settings:isTrue("autoremove_deleted_items_from_history") then
|
|
|
|
self:clearMissing()
|
|
|
|
end
|
2017-07-19 12:56:17 +00:00
|
|
|
self:_reduce()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-10 05:50:39 +00:00
|
|
|
function ReadHistory:_init()
|
|
|
|
self:reload()
|
|
|
|
end
|
|
|
|
|
2016-04-18 22:38:14 +00:00
|
|
|
ReadHistory:_init()
|
|
|
|
|
|
|
|
return ReadHistory
|