show the empty card message on the back of the card as well

Otherwise when viewing the back side, user can end up with an empty
screen.
This commit is contained in:
Damien Elmes 2021-03-01 15:32:31 +10:00
parent 14cc81f837
commit f764753920

View File

@ -558,9 +558,8 @@ pub fn render_card(
.map_err(|e| template_error_to_anki_error(e, true, i18n))?;
// check if the front side was empty
if is_cloze {
if cloze_is_empty(field_map, card_ord) {
let info = format!(
let empty_message = if is_cloze && cloze_is_empty(field_map, card_ord) {
Some(format!(
"<div>{}<br><a href='{}'>{}</a></div>",
i18n.trn(
TR::CardTemplateRenderingMissingCloze,
@ -568,17 +567,20 @@ pub fn render_card(
),
TEMPLATE_BLANK_CLOZE_LINK,
i18n.tr(TR::CardTemplateRenderingMoreInfo)
);
qnodes.push(RenderedNode::Text { text: info });
}
} else if !qtmpl.renders_with_fields(context.nonempty_fields) {
let info = format!(
))
} else if !is_cloze && !qtmpl.renders_with_fields(context.nonempty_fields) {
Some(format!(
"<div>{}<br><a href='{}'>{}</a></div>",
i18n.tr(TR::CardTemplateRenderingEmptyFront),
TEMPLATE_BLANK_LINK,
i18n.tr(TR::CardTemplateRenderingMoreInfo)
);
qnodes.push(RenderedNode::Text { text: info });
))
} else {
None
};
if let Some(text) = empty_message {
qnodes.push(RenderedNode::Text { text: text.clone() });
return Ok((qnodes, vec![RenderedNode::Text { text }]));
}
// answer side