mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user