From e0d285f085c8d1387ed588d8f1983c3d49a2baa7 Mon Sep 17 00:00:00 2001 From: weijiuqiao <59040746+weijiuqiao@users.noreply.github.com> Date: Tue, 21 Apr 2026 22:42:12 +0800 Subject: [PATCH] vocabbuilder.koplugin: Add forgot button in "Vocabulary exists" popup window (#15297) --- plugins/vocabbuilder.koplugin/db.lua | 16 ++++++++++------ plugins/vocabbuilder.koplugin/main.lua | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/plugins/vocabbuilder.koplugin/db.lua b/plugins/vocabbuilder.koplugin/db.lua index 19b731531..89629cc24 100644 --- a/plugins/vocabbuilder.koplugin/db.lua +++ b/plugins/vocabbuilder.koplugin/db.lua @@ -303,7 +303,7 @@ end function VocabularyBuilder:hasWord(word) local conn = SQ3.open(db_location) - local sql = [[SELECT title.name as book_title, create_time, due_time, prev_context, next_context, highlight + local sql = [[SELECT title.name as book_title, vocabulary.word, create_time, review_time, due_time, review_count, streak_count, prev_context, next_context, highlight FROM vocabulary INNER JOIN title ON title_id = title.id WHERE word = ?]] local stmt = conn:prepare(sql) stmt:bind(word) @@ -312,11 +312,15 @@ function VocabularyBuilder:hasWord(word) if result then return { book_title = result[1], - create_time = tonumber(result[2]), - due_time = tonumber(result[3]), - prev_context = result[4], - next_context = result[5], - highlight = result[6], + word = result[2], + create_time = tonumber(result[3]), + review_time = tonumber(result[4]), + due_time = tonumber(result[5]), + review_count = tonumber(result[6]), + streak_count = tonumber(result[7]), + prev_context = result[8], + next_context = result[9], + highlight = result[10], } else return nil diff --git a/plugins/vocabbuilder.koplugin/main.lua b/plugins/vocabbuilder.koplugin/main.lua index c543bd951..b7aac1236 100644 --- a/plugins/vocabbuilder.koplugin/main.lua +++ b/plugins/vocabbuilder.koplugin/main.lua @@ -553,6 +553,15 @@ function WordInfoDialog:init() UIManager:close(self) end } + + local forgot_button = { + text = _("Forgot"), + callback = function() + self.forgot_callback() + UIManager:close(self) + end + } + local update_button = { text = _("Overwrite"), callback = function() @@ -561,7 +570,7 @@ function WordInfoDialog:init() end } - local buttons = self.update_callback and {{cancel_button, update_button}} or {{reset_button, remove_button}} + local buttons = self.update_callback and {{cancel_button, forgot_button, update_button}} or {{reset_button, remove_button}} if self.vocabbuilder and self.vocabbuilder.item.last_due_time then table.insert(buttons, {{ text = _("Undo study status"), @@ -2102,6 +2111,10 @@ function VocabBuilder:onWordLookedUp(word, title, is_manual) prev_context = item.prev_context, next_context = item.next_context, update_callback = update, + forgot_callback = function() + DB:gotOrForgot(item, false) + DB:batchUpdateItems({ item }) + end, } UIManager:show(dialog) else