Highlights backup fix (#8479)

Fixes opening book with old highlights, when (after deleting the last highlight on a page) empty table of highlights for this page was not deleted.
reviewable/pr8481/r1
hius07 10 months ago committed by GitHub
parent e9ba854ff0
commit e66b26865b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      frontend/apps/reader/modules/readerview.lua

@ -792,7 +792,15 @@ function ReaderView:onReadSettings(config)
self.highlight.saved = config:readSetting("highlight", {})
-- Highlight formats in crengine and mupdf are incompatible.
-- Backup highlights when the document is opened with incompatible engine.
local _, page_highlights = next(self.highlight.saved) -- get the first page with highlights
local page, page_highlights
while true do -- remove empty tables for pages without highlights and get the first page with highlights
page, page_highlights = next(self.highlight.saved)
if not page or #page_highlights > 0 then
break -- we're done (there is none, or there is some usable)
else
self.highlight.saved[page] = nil -- clean it up while we're at it, and find another one
end
end
if page_highlights then
local highlight_type = type(page_highlights[1].pos0)
if self.ui.rolling and highlight_type == "table" then

Loading…
Cancel
Save