Skip to content

Commit

Permalink
Statistics: Don't blow up when annotating/highlighting stuff with the…
Browse files Browse the repository at this point in the history
… plugin loaded,

but disabled

Re koreader#6825
Re koreader#6827
  • Loading branch information
NiLuJe committed Oct 25, 2020
1 parent 144fd78 commit a192dda
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions plugins/statistics.koplugin/main.lua
Expand Up @@ -2221,19 +2221,23 @@ function ReaderStatistics:onCloseDocument()
end

function ReaderStatistics:onAddHighlight()
self.data.highlights = self.data.highlights + 1
return true
if self.is_enabled then
self.data.highlights = self.data.highlights + 1
end
end

function ReaderStatistics:onDelHighlight()
if self.data.highlights > 0 then
self.data.highlights = self.data.highlights - 1
if self.is_enabled then
if self.data.highlights > 0 then
self.data.highlights = self.data.highlights - 1
end
end
return true
end

function ReaderStatistics:onAddNote()
self.data.notes = self.data.notes + 1
if self.is_enabled then
self.data.notes = self.data.notes + 1
end
end

-- Triggered by auto_save_settings_interval_minutes
Expand Down

0 comments on commit a192dda

Please sign in to comment.