From f5a6b25e8d3331fce1cc5145bb7b21f2081743fe Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:25:53 -0400 Subject: Fix noteInfos not getting assigned (#819) --- ext/js/background/backend.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'ext/js/background') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 569cb53d..881cd241 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -609,10 +609,14 @@ export class Backend { const valid = isNoteDataValid(note); + const noteIds = isDuplicate ? duplicateNoteIds[originalIndices.indexOf(i)] : null; + const noteInfos = (fetchAdditionalInfo && noteIds !== null && noteIds.length > 0) ? await this._anki.notesInfo(noteIds) : []; + const info = { canAdd: valid, valid, - noteIds: isDuplicate ? duplicateNoteIds[originalIndices.indexOf(i)] : null + noteIds: noteIds, + noteInfos: noteInfos }; results.push(info); @@ -622,20 +626,6 @@ export class Backend { } } - if (cannotAdd.length > 0) { - const cannotAddNotes = cannotAdd.map(({note}) => note); - const noteIdsArray = await this._anki.findNoteIds(cannotAddNotes); - for (let i = 0, ii = Math.min(cannotAdd.length, noteIdsArray.length); i < ii; ++i) { - const noteIds = noteIdsArray[i]; - if (noteIds.length > 0) { - cannotAdd[i].info.noteIds = noteIds; - if (fetchAdditionalInfo) { - cannotAdd[i].info.noteInfos = await this._anki.notesInfo(noteIds); - } - } - } - } - return results; } -- cgit v1.2.3