summaryrefslogtreecommitdiff
path: root/ext/js/display/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-26 19:31:19 -0400
committerGitHub <noreply@github.com>2021-03-26 19:31:19 -0400
commit482dd8c8d8339d29c9e7a202cbf4c54bf7cf291d (patch)
treedba1d8d79f01ff8cb7a14b80269ec301dc4e72b4 /ext/js/display/display.js
parenta14caaeab92027c57545f9db40c29e6afac14993 (diff)
Display fixes (#1560)
* Fix _getDefinitionDetailsForNote * Fix _getExpressionAndReading
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r--ext/js/display/display.js33
1 files changed, 19 insertions, 14 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 1142f36f..7cc3b437 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -1505,7 +1505,7 @@ class Display extends EventDispatcher {
let audioDetails = null;
if (definitionDetails.type !== 'kanji' && AnkiUtil.fieldsObjectContainsMarker(fields, 'audio')) {
- const primaryCardAudio = this._displayAudio.getPrimaryCardAudio(definitionDetails.expression, definitionDetails.reading);
+ const primaryCardAudio = this._displayAudio.getPrimaryCardAudio(definitionDetails.term, definitionDetails.reading);
let preferredAudioIndex = null;
let sources2 = sources;
if (primaryCardAudio !== null) {
@@ -1531,26 +1531,31 @@ class Display extends EventDispatcher {
);
}
- _getDefinitionDetailsForNote(definition) {
- const {type} = definition;
+ _getDefinitionDetailsForNote(dictionaryEntry) {
+ const {type} = dictionaryEntry;
if (type === 'kanji') {
- const {character} = definition;
+ const {character} = dictionaryEntry;
return {type, character};
}
- const termDetailsList = definition.expressions;
+ const {headwords} = dictionaryEntry;
let bestIndex = -1;
- for (let i = 0, ii = termDetailsList.length; i < ii; ++i) {
- const {sourceTerm, expression, reading} = termDetailsList[i];
- if (expression === sourceTerm) {
- bestIndex = i;
- break;
- } else if (reading === sourceTerm && bestIndex < 0) {
- bestIndex = i;
+ for (let i = 0, ii = headwords.length; i < ii; ++i) {
+ const {term, reading, sources} = headwords[i];
+ for (const {deinflectedText} of sources) {
+ if (term === deinflectedText) {
+ bestIndex = i;
+ i = ii;
+ break;
+ } else if (reading === deinflectedText && bestIndex < 0) {
+ bestIndex = i;
+ break;
+ }
}
}
- const {expression, reading} = termDetailsList[Math.max(0, bestIndex)];
- return {type, expression, reading};
+
+ const {term, reading} = headwords[Math.max(0, bestIndex)];
+ return {type, term, reading};
}
async _setOptionsContextIfDifferent(optionsContext) {