Backup and restore bookmarks/highlights when switching engines (#8455)
Bookmark/highlight formats in crengine and mupdf are incompatible. This backups and restores bookmarks and highlights when opening the document with an incompatible engine, instead of deleting them.
This commit is contained in:
1 parent
6f2fdd96f8
commit
0eeb8bd2b7
3 files changed
+33
-24
No files matched your search
@@ -264,7 +264,22 @@ function ReaderBookmark:importSavedHighlight(config)
|
||||
end
|
||||
|
||||
function ReaderBookmark:onReadSettings(config)
|
||||
self.bookmarks = config:readSetting("bookmarks") or {}
|
||||
self.bookmarks = config:readSetting("bookmarks", {})
|
||||
-- Bookmark formats in crengine and mupdf are incompatible.
|
||||
-- Backup bookmarks when the document is opened with incompatible engine.
|
||||
if #self.bookmarks > 0 then
|
||||
if self.ui.rolling and type(self.bookmarks[1].page) == "number" then
|
||||
config:saveSetting("bookmarks_paging", self.bookmarks)
|
||||
self.bookmarks = config:readSetting("bookmarks_rolling", {})
|
||||
config:saveSetting("bookmarks", self.bookmarks)
|
||||
config:delSetting("bookmarks_rolling")
|
||||
elseif self.ui.paging and type(self.bookmarks[1].page) == "string" then
|
||||
config:saveSetting("bookmarks_rolling", self.bookmarks)
|
||||
self.bookmarks = config:readSetting("bookmarks_paging", {})
|
||||
config:saveSetting("bookmarks", self.bookmarks)
|
||||
config:delSetting("bookmarks_paging")
|
||||
end
|
||||
end
|
||||
-- need to do this after initialization because checking xpointer
|
||||
-- may cause segfaults before credocuments are inited.
|
||||
self.ui:registerPostInitCallback(function()
|
||||
|
||||
Reference in new issue
Block a user