From ba3f7b3e96df7f034b56132d8c2c90289e16c288 Mon Sep 17 00:00:00 2001 From: soriac Date: Fri, 30 Apr 2021 18:57:53 -0300 Subject: Show any custom tags on words that have anki cards created (#1628) * Proof-of-concept for showing card tags (#1626) * Resolved most PR comments: - Added a snackbar notification when clicking tag button - Replaced magnifying glass icon with new tag icon - Button now contains a span w/icon, to use text color - Removed unnecessary attributes from button - Backend now returns full noteInfos object - Frontend now handles filtering tags * Add options to show/hide tag button & filter tags * Do not show tags button if, after filtering, we have zero tags. * Change tags option to enums, optimize tags intersection check & fix code style. * Update options-util.js to include new tag options. * Fix wording on new tag setting. * Add CSS to remove hidden buttons from the display layout. * getAnkiNoteInfo extra parameter for additional info. * Add new tag option to tests. * Remove unnecessary changes related to anki tags option. * Code style fixes. --- ext/js/background/backend.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ext/js/background') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 5b133d79..e94ad065 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -458,7 +458,7 @@ class Backend { return await this._anki.addNote(note); } - async _onApiGetAnkiNoteInfo({notes}) { + async _onApiGetAnkiNoteInfo({notes, fetchAdditionalInfo}) { const results = []; const cannotAdd = []; const canAddArray = await this._anki.canAddNotes(notes); @@ -482,6 +482,9 @@ class Backend { const noteIds = noteIdsArray[i]; if (noteIds.length > 0) { cannotAdd[i].info.noteIds = noteIds; + if (fetchAdditionalInfo) { + cannotAdd[i].info.noteInfos = await this._anki.notesInfo(noteIds); + } } } } -- cgit v1.2.3