diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-06-26 14:10:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-26 14:10:18 -0400 |
commit | 435af3a485c5938ca1ff808d456d786735a3ea18 (patch) | |
tree | 23fd566c593872093504f3881dc75cff1108efee /ext/js/display/display.js | |
parent | 845070b8170d6f8e6e9e1dbed8d6da39678cbd81 (diff) |
Improve what info is logged when debugging a definition (#1756)
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r-- | ext/js/display/display.js | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 26c1e06c..28659294 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -1073,7 +1073,7 @@ class Display extends EventDispatcher { try { this._updateAdderButtonsPromise = promise; - const modes = isTerms ? ['term-kanji', 'term-kana'] : ['kanji']; + const modes = this._getModes(isTerms); let states; try { const noteContext = this._getNoteContext(); @@ -1922,9 +1922,16 @@ class Display extends EventDispatcher { return typeof queryPostProcessor === 'function' ? queryPostProcessor(query) : query; } + _getModes(isTerms) { + return isTerms ? ['term-kanji', 'term-kana'] : ['kanji']; + } + async _logDictionaryEntryData(index) { if (index < 0 || index >= this._dictionaryEntries.length) { return; } const dictionaryEntry = this._dictionaryEntries[index]; + const result = {dictionaryEntry}; + + // Anki note data let ankiNoteData; let ankiNoteDataException; try { @@ -1943,10 +1950,32 @@ class Display extends EventDispatcher { } catch (e) { ankiNoteDataException = e; } - const result = {dictionaryEntry, ankiNoteData}; + result.ankiNoteData = ankiNoteData; if (typeof ankiNoteDataException !== 'undefined') { result.ankiNoteDataException = ankiNoteDataException; } + + // Anki notes + const ankiNotes = []; + const modes = this._getModes(dictionaryEntry.type === 'term'); + for (const mode of modes) { + let ankiNote; + let ankiNoteException; + const ankiNoteErrors = []; + try { + const noteContext = this._getNoteContext(); + ankiNote = await this._createNote(dictionaryEntry, mode, noteContext, false, ankiNoteErrors); + } catch (e) { + ankiNoteException = e; + } + const entry = {mode, ankiNote}; + if (typeof ankiNoteException !== 'undefined') { + entry.ankiNoteException = ankiNoteException; + } + ankiNotes.push(entry); + } + result.ankiNotes = ankiNotes; + console.log(result); } } |