Statistics: fix number of highlights (#6173)

This number might have been leaking from a previously opened
book, and can be innacurate.
Reset it from the number of highlights stored in settings.
Note that the number of "Notes" shown does not mean much.
This commit is contained in:
poire-z
2020-05-20 21:40:49 +02:00
committed by GitHub
parent 8ab3bf2792
commit 39345704ec
2 changed files with 21 additions and 0 deletions

View File

@@ -639,4 +639,22 @@ function ReaderBookmark:hasBookmarks()
return self.bookmarks and #self.bookmarks > 0
end
function ReaderBookmark:getNumberOfHighlightsAndNotes()
local highlights = 0
local notes = 0
for i = 1, #self.bookmarks do
if self.bookmarks[i].highlighted then
highlights = highlights + 1
-- No real way currently to know which highlights
-- have been edited and became "notes". Editing them
-- adds this 'text' field, but just showing bookmarks
-- do that as well...
if self.bookmarks[i].text then
notes = notes + 1
end
end
end
return highlights, notes
end
return ReaderBookmark