Update readerannotation.lua

reviewable/pr11563/r7
hius07 2 months ago committed by GitHub
parent 65894540e2
commit 7e5fb006bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -169,14 +169,14 @@ function ReaderAnnotation:createAnnotations(config)
if config:has("bookmarks_paging") then -- save incompatible old backup if config:has("bookmarks_paging") then -- save incompatible old backup
local bookmarks_paging = config:readSetting("bookmarks_paging") local bookmarks_paging = config:readSetting("bookmarks_paging")
local highlights_paging = config:readSetting("highlight_paging") local highlights_paging = config:readSetting("highlight_paging")
local annotations_paging = self:getAnnotationsFromBookmarksHighlights(bookmarks_paging, highlights_paging) local annotations = self:getAnnotationsFromBookmarksHighlights(bookmarks_paging, highlights_paging)
config:saveSetting("annotations_paging", annotations_paging) config:saveSetting("annotations_paging", annotations)
config:delSetting("bookmarks_paging") config:delSetting("bookmarks_paging")
config:delSetting("highlight_paging") config:delSetting("highlight_paging")
end end
else -- incompatible format loaded, or empty else -- incompatible format loaded, or empty
if has_bookmarks then -- save incompatible format if not empty if has_bookmarks then -- save incompatible format if not empty
annotations = self:getAnnotationsFromBookmarksHighlights(bookmarks, highlights) local annotations = self:getAnnotationsFromBookmarksHighlights(bookmarks, highlights)
config:saveSetting("annotations_paging", annotations) config:saveSetting("annotations_paging", annotations)
end end
-- load compatible format -- load compatible format
@ -190,14 +190,14 @@ function ReaderAnnotation:createAnnotations(config)
if config:has("bookmarks_rolling") then if config:has("bookmarks_rolling") then
local bookmarks_rolling = config:readSetting("bookmarks_rolling") local bookmarks_rolling = config:readSetting("bookmarks_rolling")
local highlights_rolling = config:readSetting("highlight_rolling") local highlights_rolling = config:readSetting("highlight_rolling")
local annotations_rolling = self:getAnnotationsFromBookmarksHighlights(bookmarks_rolling, highlights_rolling) local annotations = self:getAnnotationsFromBookmarksHighlights(bookmarks_rolling, highlights_rolling)
config:saveSetting("annotations_rolling", annotations_rolling) config:saveSetting("annotations_rolling", annotations)
config:delSetting("bookmarks_rolling") config:delSetting("bookmarks_rolling")
config:delSetting("highlight_rolling") config:delSetting("highlight_rolling")
end end
else else
if has_bookmarks then if has_bookmarks then
annotations = self:getAnnotationsFromBookmarksHighlights(bookmarks, highlights) local annotations = self:getAnnotationsFromBookmarksHighlights(bookmarks, highlights)
config:saveSetting("annotations_rolling", annotations) config:saveSetting("annotations_rolling", annotations)
end end
bookmarks = config:readSetting("bookmarks_paging") or {} bookmarks = config:readSetting("bookmarks_paging") or {}
@ -317,7 +317,7 @@ function ReaderAnnotation:getItemIndex(item, no_binary)
end end
end end
end end
if not no_binary then if not no_binary then
local isInOrder = self.ui.rolling and self.isItemInPositionOrderRolling or self.isItemInPositionOrderPaging local isInOrder = self.ui.rolling and self.isItemInPositionOrderRolling or self.isItemInPositionOrderPaging
local _start, _end, _middle = 1, #self.annotations local _start, _end, _middle = 1, #self.annotations
@ -333,7 +333,7 @@ function ReaderAnnotation:getItemIndex(item, no_binary)
end end
end end
end end
for i, v in ipairs(self.annotations) do for i, v in ipairs(self.annotations) do
if doesMatch(item, v) then if doesMatch(item, v) then
return i return i

Loading…
Cancel
Save