Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statistics: Don't blow up when annotating/highlighting stuff with the plugin loaded, but disabled #6829

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions plugins/statistics.koplugin/main.lua
Original file line number Diff line number Diff line change
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