Skip to content

Commit

Permalink
Don't generate caption if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Sep 10, 2024
1 parent ce3dbb0 commit 78dc595
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions repology-webapp/src/views/badges/vertical_allrepos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,21 @@ pub async fn badge_vertical_allrepos(
}
}

let caption = query.caption.as_ref().map_or(
if cells.is_empty() {
"No known packages"
} else {
"Packaging status"
let caption = query.caption.as_ref().map_or_else(
|| {
if cells.is_empty() {
Some("No known packages")
} else {
Some("Packaging status")
}
},
|caption| {
if caption.is_empty() {
None
} else {
Some(&caption)
}
},
String::as_str,
);

let num_columns = query.columns_count.min(cells.len());
Expand All @@ -171,7 +179,7 @@ pub async fn badge_vertical_allrepos(
}
};

let body = render_generic_badge(&cells, Some(caption), 0, &state.font_measurer)?;
let body = render_generic_badge(&cells, caption, 0, &state.font_measurer)?;

Ok((
[(
Expand Down

0 comments on commit 78dc595

Please sign in to comment.