From b81f9969d959f174444e500d63a5f47cde5d38b3 Mon Sep 17 00:00:00 2001 From: Emil Hammarberg Date: Thu, 11 Sep 2025 14:00:29 +0200 Subject: [PATCH 1/2] Display first field instead of note ID --- ankiconnect.lua | 17 +++++++++++++++++ subs2srs.lua | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ankiconnect.lua b/ankiconnect.lua index e04f1d5..2b0ea4e 100644 --- a/ankiconnect.lua +++ b/ankiconnect.lua @@ -191,6 +191,23 @@ self.get_first_field = function(model_name) end end +self.get_field = function(note_id, field) + local ret = self.execute { + action = "cardsInfo", + version = 6, + params = { + cards = { note_id } + } + } + + local result, error = self.parse_result(ret) + + if error == nil then + return result[1].fields[field].value + end + +end + self.gui_browse = function(query) --- query is a string, e.g. "deck:current", "nid:12345" if not self.config.disable_gui_browse then diff --git a/subs2srs.lua b/subs2srs.lua index 26fa623..ab51b54 100644 --- a/subs2srs.lua +++ b/subs2srs.lua @@ -437,11 +437,14 @@ local function notify_user_on_finish(note_ids) local query = table.concat(queries, " OR ") ankiconnect.gui_browse(query) + local first_field = ankiconnect.get_first_field(config.model_name) + -- Notify the user. if #note_ids > 1 then h.notify(string.format("Updated %i notes.", #note_ids)) else - h.notify(string.format("Updated note #%s.", tostring(note_ids[1]))) + field_data = ankiconnect.get_field(note_ids[1], first_field) + h.notify(string.format("Updated note: %s.", field_data)) end end From 3a82925476fd397c5ec34c5fdadf6aefcbdd0b57 Mon Sep 17 00:00:00 2001 From: Emil Hammarberg Date: Fri, 12 Sep 2025 02:01:56 +0200 Subject: [PATCH 2/2] Remove unnecessary new function --- ankiconnect.lua | 17 ----------------- subs2srs.lua | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/ankiconnect.lua b/ankiconnect.lua index 2b0ea4e..e04f1d5 100644 --- a/ankiconnect.lua +++ b/ankiconnect.lua @@ -191,23 +191,6 @@ self.get_first_field = function(model_name) end end -self.get_field = function(note_id, field) - local ret = self.execute { - action = "cardsInfo", - version = 6, - params = { - cards = { note_id } - } - } - - local result, error = self.parse_result(ret) - - if error == nil then - return result[1].fields[field].value - end - -end - self.gui_browse = function(query) --- query is a string, e.g. "deck:current", "nid:12345" if not self.config.disable_gui_browse then diff --git a/subs2srs.lua b/subs2srs.lua index ab51b54..ad99836 100644 --- a/subs2srs.lua +++ b/subs2srs.lua @@ -443,7 +443,7 @@ local function notify_user_on_finish(note_ids) if #note_ids > 1 then h.notify(string.format("Updated %i notes.", #note_ids)) else - field_data = ankiconnect.get_field(note_ids[1], first_field) + field_data = ankiconnect.get_note_fields(note_ids[1])[first_field] h.notify(string.format("Updated note: %s.", field_data)) end end