Use trash-rs' is_empty more

Fixes two instances where enumerating trash items isn't needed.
This commit is contained in:
Josh Megnauth 2025-07-22 02:52:44 -04:00 committed by Jeremy Soller
parent 3390ef7ea8
commit 35a9bd5347
2 changed files with 9 additions and 9 deletions

View file

@ -2262,14 +2262,14 @@ impl Application for App {
NavMenuAction::RemoveFromSidebar(entity),
));
}
if matches!(location_opt, Some(Location::Trash)) {
if tab::trash_entries() > 0 {
items.push(cosmic::widget::menu::Item::Button(
fl!("empty-trash"),
None,
NavMenuAction::EmptyTrash,
));
}
if matches!(location_opt, Some(Location::Trash))
&& !trash::os_limited::is_empty().unwrap_or(true)
{
items.push(cosmic::widget::menu::Item::Button(
fl!("empty-trash"),
None,
NavMenuAction::EmptyTrash,
));
}
Some(cosmic::widget::menu::items(&HashMap::new(), items))

View file

@ -160,7 +160,7 @@ pub fn context_menu<'a>(
) => {
if selected_trash_only {
children.push(menu_item(fl!("open"), Action::Open).into());
if tab::trash_entries() > 0 {
if !trash::os_limited::is_empty().unwrap_or(true) {
children.push(menu_item(fl!("empty-trash"), Action::EmptyTrash).into());
}
} else if let Some(entry) = selected_desktop_entry {