Display fixes (#1560)
* Fix _getDefinitionDetailsForNote * Fix _getExpressionAndReading
This commit is contained in:
parent
a14caaeab9
commit
482dd8c8d8
@ -405,11 +405,11 @@ class DisplayAudio {
|
|||||||
const definition = definitions[definitionIndex];
|
const definition = definitions[definitionIndex];
|
||||||
if (definition.type === 'kanji') { return null; }
|
if (definition.type === 'kanji') { return null; }
|
||||||
|
|
||||||
const {expressions} = definition;
|
const {headwords} = definition;
|
||||||
if (expressionIndex < 0 || expressionIndex >= expressions.length) { return null; }
|
if (expressionIndex < 0 || expressionIndex >= headwords.length) { return null; }
|
||||||
|
|
||||||
const {expression, reading} = expressions[expressionIndex];
|
const {term, reading} = headwords[expressionIndex];
|
||||||
return {expression, reading};
|
return {expression: term, reading};
|
||||||
}
|
}
|
||||||
|
|
||||||
_getExpressionReadingKey(expression, reading) {
|
_getExpressionReadingKey(expression, reading) {
|
||||||
|
@ -1505,7 +1505,7 @@ class Display extends EventDispatcher {
|
|||||||
|
|
||||||
let audioDetails = null;
|
let audioDetails = null;
|
||||||
if (definitionDetails.type !== 'kanji' && AnkiUtil.fieldsObjectContainsMarker(fields, 'audio')) {
|
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 preferredAudioIndex = null;
|
||||||
let sources2 = sources;
|
let sources2 = sources;
|
||||||
if (primaryCardAudio !== null) {
|
if (primaryCardAudio !== null) {
|
||||||
@ -1531,26 +1531,31 @@ class Display extends EventDispatcher {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getDefinitionDetailsForNote(definition) {
|
_getDefinitionDetailsForNote(dictionaryEntry) {
|
||||||
const {type} = definition;
|
const {type} = dictionaryEntry;
|
||||||
if (type === 'kanji') {
|
if (type === 'kanji') {
|
||||||
const {character} = definition;
|
const {character} = dictionaryEntry;
|
||||||
return {type, character};
|
return {type, character};
|
||||||
}
|
}
|
||||||
|
|
||||||
const termDetailsList = definition.expressions;
|
const {headwords} = dictionaryEntry;
|
||||||
let bestIndex = -1;
|
let bestIndex = -1;
|
||||||
for (let i = 0, ii = termDetailsList.length; i < ii; ++i) {
|
for (let i = 0, ii = headwords.length; i < ii; ++i) {
|
||||||
const {sourceTerm, expression, reading} = termDetailsList[i];
|
const {term, reading, sources} = headwords[i];
|
||||||
if (expression === sourceTerm) {
|
for (const {deinflectedText} of sources) {
|
||||||
bestIndex = i;
|
if (term === deinflectedText) {
|
||||||
break;
|
bestIndex = i;
|
||||||
} else if (reading === sourceTerm && bestIndex < 0) {
|
i = ii;
|
||||||
bestIndex = i;
|
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) {
|
async _setOptionsContextIfDifferent(optionsContext) {
|
||||||
|
Loading…
Reference in New Issue
Block a user