From d5a4ac14e1154af4234593f03b95e61365ae12eb Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sat, 7 Jan 2023 08:09:16 +0200 Subject: [PATCH] ReaderUI: fix status and history (#9993) --- frontend/apps/reader/readerui.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/apps/reader/readerui.lua b/frontend/apps/reader/readerui.lua index 9f0f6d819..05f70b9fc 100644 --- a/frontend/apps/reader/readerui.lua +++ b/frontend/apps/reader/readerui.lua @@ -455,6 +455,19 @@ function ReaderUI:init() -- Book information). self.doc_settings:saveSetting("doc_props", self.document:getProps()) + -- Set "reading" status if there is no status. + local summary = self.doc_settings:readSetting("summary") + if not (summary and summary.status) then + if not summary then + summary = {} + end + summary.status = "reading" + summary.modified = os.date("%Y-%m-%d", os.time()) + self.doc_settings:saveSetting("summary", summary) + end + + require("readhistory"):addItem(self.document.file) -- (will update "lastfile") + -- After initialisation notify that document is loaded and rendered -- CREngine only reports correct page count after rendering is done -- Need the same event for PDF document @@ -626,7 +639,6 @@ function ReaderUI:doShowReader(file, provider) end end end - require("readhistory"):addItem(file) -- (will update "lastfile") local reader = ReaderUI:new{ dimen = Screen:getSize(), covers_fullscreen = true, -- hint for UIManager:_repaint() @@ -794,10 +806,6 @@ function ReaderUI:dealWithLoadDocumentFailure() -- We can't do much more than crash properly here (still better than -- going on and segfaulting when calling other methods on unitiliazed -- _document) - -- We must still remove it from lastfile and history (as it has - -- already been added there) so that koreader don't crash again - -- at next launch... - require("readhistory"):removeItemByPath(self.document.file) -- (will update "lastfile") -- As we are in a coroutine, we can pause and show an InfoMessage before exiting local _coroutine = coroutine.running() if coroutine then