refactor: simplify mime type limit logic
This commit is contained in:
parent
361465e337
commit
b1771b4c42
1 changed files with 7 additions and 16 deletions
23
src/tab.rs
23
src/tab.rs
|
|
@ -5941,29 +5941,20 @@ impl Tab {
|
||||||
mime_types.sort_by(|(_, v1), (_, v2)| v2.cmp(v1));
|
mime_types.sort_by(|(_, v1), (_, v2)| v2.cmp(v1));
|
||||||
|
|
||||||
// Limit the number of displayed mime types
|
// Limit the number of displayed mime types
|
||||||
mime_types.truncate(10);
|
let limit = usize::min(10, mime_types.len());
|
||||||
|
|
||||||
let mut mime_types_total: u64 = 0;
|
let mut mime_type_strings: Vec<String> = mime_types[..limit]
|
||||||
|
.iter()
|
||||||
let mut mime_types: Vec<String> = mime_types
|
.map(|(mime, count)| format!("{} ({})", mime, count))
|
||||||
.into_iter()
|
|
||||||
.map(|(mime, count)| {
|
|
||||||
mime_types_total += count;
|
|
||||||
format!("{} ({})", mime, count)
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if selected_items
|
if mime_types.len() > limit {
|
||||||
.len()
|
mime_type_strings.push("...".to_string());
|
||||||
.saturating_sub(mime_types_total as usize)
|
|
||||||
> 0
|
|
||||||
{
|
|
||||||
mime_types.push(format!("..."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
details = details.push(widget::text::body(fl!(
|
details = details.push(widget::text::body(fl!(
|
||||||
"type",
|
"type",
|
||||||
mime = mime_types.join(", ")
|
mime = mime_type_strings.join(", ")
|
||||||
)));
|
)));
|
||||||
|
|
||||||
let size = {
|
let size = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue