fix anki network error dialog on search page, cleanup template
workaround
This commit is contained in:
parent
922d2cd468
commit
30fe3d2506
@ -66,6 +66,9 @@ async function apiDefinitionAdd(definition, mode) {
|
||||
}
|
||||
|
||||
async function apiDefinitionsAddable(definitions, modes) {
|
||||
const states = [];
|
||||
|
||||
try {
|
||||
const notes = [];
|
||||
for (const definition of definitions) {
|
||||
for (const mode of modes) {
|
||||
@ -74,7 +77,6 @@ async function apiDefinitionsAddable(definitions, modes) {
|
||||
}
|
||||
|
||||
const results = await utilBackend().anki.canAddNotes(notes);
|
||||
const states = [];
|
||||
for (let resultBase = 0; resultBase < results.length; resultBase += modes.length) {
|
||||
const state = {};
|
||||
for (let modeOffset = 0; modeOffset < modes.length; ++modeOffset) {
|
||||
@ -84,6 +86,11 @@ async function apiDefinitionsAddable(definitions, modes) {
|
||||
states.push(state);
|
||||
}
|
||||
|
||||
return states;
|
||||
} catch (e) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
return states;
|
||||
}
|
||||
|
||||
|
@ -223,10 +223,7 @@ function dictFieldFormat(field, definition, mode, options) {
|
||||
modeKanji: mode === 'kanji'
|
||||
};
|
||||
|
||||
field = field.replace(
|
||||
`{${marker}}`,
|
||||
handlebarsRender('fields.html', data).trim()
|
||||
);
|
||||
field = field.replace(`{${marker}}`, handlebarsRender('fields.html', data));
|
||||
}
|
||||
|
||||
return field;
|
||||
|
@ -51,5 +51,5 @@ function handlebarsRender(template, data) {
|
||||
Handlebars.registerHelper('multiLine', handlebarsMultiLine);
|
||||
}
|
||||
|
||||
return Handlebars.templates[template](data);
|
||||
return Handlebars.templates[template](data).trim();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user