From f7647539204ebb617516b8714542ba0d7593113a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 1 Mar 2021 15:32:31 +1000 Subject: [PATCH] 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. --- rslib/src/template.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/rslib/src/template.rs b/rslib/src/template.rs index 46000bf4d..129253afd 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -558,27 +558,29 @@ 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!( - "
{}
{}
", - i18n.trn( - TR::CardTemplateRenderingMissingCloze, - tr_args!["number"=>card_ord+1] - ), - 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!( + let empty_message = if is_cloze && cloze_is_empty(field_map, card_ord) { + Some(format!( + "
{}
{}
", + i18n.trn( + TR::CardTemplateRenderingMissingCloze, + tr_args!["number"=>card_ord+1] + ), + TEMPLATE_BLANK_CLOZE_LINK, + i18n.tr(TR::CardTemplateRenderingMoreInfo) + )) + } else if !is_cloze && !qtmpl.renders_with_fields(context.nonempty_fields) { + Some(format!( "
{}
{}
", 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