From fd986ab865b13f1c593ab994bda42ccdf07fee78 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:48:40 +0300 Subject: [PATCH] Statistics: AnnotationsModified event --- plugins/statistics.koplugin/main.lua | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index f97ed28dd..c519bc5b4 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -2727,27 +2727,14 @@ function ReaderStatistics:onCloseDocument() self:insertDB() end -function ReaderStatistics:onAddHighlight() +function ReaderStatistics:onAnnotationsModified(diff) if self.settings.is_enabled then - self.data.highlights = self.data.highlights + 1 - end -end - -function ReaderStatistics:onDelHighlight() - if self.settings.is_enabled then - self.data.highlights = self.data.highlights - 1 - end -end - -function ReaderStatistics:onAddNote() - if self.settings.is_enabled then - self.data.notes = self.data.notes + 1 - end -end - -function ReaderStatistics:onDelNote() - if self.settings.is_enabled then - self.data.notes = self.data.notes - 1 + if diff.highlights then + self.data.highlights = self.data.highlights + diff.highlights + end + if diff.notes then + self.data.notes = self.data.notes + diff.notes + end end end