restructure an if

This commit is contained in:
Dietrich 2021-10-04 12:09:07 +02:00
parent 952e2ca296
commit 1b014841ab
Signed by: dietrich
GPG Key ID: 9F3C20C0F85DF67C
2 changed files with 9 additions and 9 deletions

View File

@ -821,14 +821,7 @@ fn edit_or_create_link<F: Fn(&str) -> String>(
],
tr![
th![t("qr-code")],
if let Loadable::Data(Some(qr)) = qr {
td![a![
span![C!["qrdownload"], "Download", raw!(&qr.svg),],
attrs!(At::Href => qr.url, At::Download => "qr-code.png")
]]
} else {
td!["Loading..."]
}
qr.as_ref().map_or_else(|| td!["Loading..."], render_qr),
]
],
a![
@ -842,6 +835,13 @@ fn edit_or_create_link<F: Fn(&str) -> String>(
]
}
fn render_qr(qr: &QrGuard) -> Node<Msg> {
td![a![
span![C!["qrdownload"], "Download", raw!(&qr.svg),],
attrs!(At::Href => qr.url, At::Download => "qr-code.png")
]]
}
/// generate a qr-code for a code
fn generate_qr_from_code(code: &str) -> String {
generate_qr_from_link(&format!("https://{}/{}", get_host(), code))

View File

@ -393,7 +393,7 @@ fn view_user_table_head<F: Fn(&str) -> String>(t: F) -> Node<Msg> {
]
}
/// Display the filterboxes below the headlines
/// Display the filter-boxes below the headlines
fn view_user_table_filter_input<F: Fn(&str) -> String>(model: &Model, t: F) -> Node<Msg> {
tr![
C!["filters"],