From 20ac8004d65089764cad517dcf1f4c44919d2677 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Wed, 4 Jan 2023 02:24:23 +0200 Subject: [PATCH] ReadHistory: further minor refactoring (#9991) --- frontend/readhistory.lua | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/frontend/readhistory.lua b/frontend/readhistory.lua index 2afc7782a..2b96f65ae 100644 --- a/frontend/readhistory.lua +++ b/frontend/readhistory.lua @@ -118,6 +118,7 @@ function ReadHistory:_flush() ffiutil.fsyncOpenedFile(f) -- force flush to the storage device f:close() end + self:ensureLastFile() end --- Reads history table from file. @@ -163,7 +164,6 @@ function ReadHistory:_readLegacyHistory() if history_updated then self:_reduce() self:_flush() - self:ensureLastFile() end end @@ -182,11 +182,6 @@ function ReadHistory:ensureLastFile() G_reader_settings:saveSetting("lastfile", last_existing_file) end -function ReadHistory:getLastFile() - self:ensureLastFile() - return G_reader_settings:readSetting("lastfile") -end - --- 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). @@ -224,10 +219,6 @@ function ReadHistory:updateItemByPath(old_path, new_path) self:_flush() self:reload(true) end - if G_reader_settings:readSetting("lastfile") == old_path then - G_reader_settings:saveSetting("lastfile", new_path) - end - self:ensureLastFile() end --- Updates the history list after deleting a file. @@ -246,7 +237,6 @@ end --- Removes the history item if the document settings has been reset. function ReadHistory:fileSettingsPurged(path) if G_reader_settings:isTrue("autoremove_deleted_items_from_history") then - -- Also remove it from history on purge when that setting is enabled self:removeItemByPath(path) end end @@ -262,7 +252,6 @@ function ReadHistory:clearMissing() end if history_updated then self:_flush() - self:ensureLastFile() end end @@ -279,7 +268,6 @@ function ReadHistory:removeItem(item, idx, no_flush) os.remove(DocSettings:getHistoryPath(item.file)) if not no_flush then self:_flush() - self:ensureLastFile() end end @@ -306,7 +294,6 @@ function ReadHistory:addItem(file, ts, no_flash) if not no_flash then self:_reduce() self:_flush() - self:ensureLastFile() end return true -- used while adding legacy items end