Skip to content

Commit 5fb048c

Browse files
authored
Display first field instead of note ID (#148)
* Display first field instead of note ID * Remove unnecessary new function * Handle empty and long fields
1 parent eb639e0 commit 5fb048c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

subs2srs.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,22 @@ local function notify_user_on_finish(note_ids)
437437
local query = table.concat(queries, " OR ")
438438
ankiconnect.gui_browse(query)
439439

440+
local first_field = ankiconnect.get_first_field(config.model_name)
441+
440442
-- Notify the user.
441443
if #note_ids > 1 then
442444
h.notify(string.format("Updated %i notes.", #note_ids))
443445
else
444-
h.notify(string.format("Updated note #%s.", tostring(note_ids[1])))
446+
field_data = ankiconnect.get_note_fields(note_ids[1])[first_field]
447+
if not h.is_empty(field_data) then
448+
local max_len = 20
449+
if string.len(field_data) > max_len then
450+
field_data = field_data:sub(1, max_len) .. ""
451+
end
452+
h.notify(string.format("Updated note: %s.", field_data))
453+
else
454+
h.notify(string.format("Updated note #%s.", tostring(note_ids[1])))
455+
end
445456
end
446457
end
447458

0 commit comments

Comments
 (0)