use 'map' rather than 'and_then'

This commit is contained in:
daniel.eades 2023-11-16 17:38:32 +00:00 • committed by Ashley Wulber
parent 9dcc3fcc35
commit 068560e921

View file

@ -628,22 +628,20 @@ impl cosmic::Application for CosmicAppList {
Message::DndData(file_path) => { Message::DndData(file_path) => {
if let Some(DndOffer { dock_item, .. }) = self.dnd_offer.as_mut() { if let Some(DndOffer { dock_item, .. }) = self.dnd_offer.as_mut() {
if let Some(di) = std::fs::read_to_string(&file_path).ok().and_then(|input| { if let Some(di) = std::fs::read_to_string(&file_path).ok().and_then(|input| {
DesktopEntry::decode(&file_path, &input) DesktopEntry::decode(&file_path, &input).ok().map(|de| {
.ok()
.and_then(|de| {
let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid)) let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid))
.with_size(128) .with_size(128)
.with_cache() .with_cache()
.find() .find()
.unwrap_or_else(default_app_icon); .unwrap_or_else(default_app_icon);
Some(DesktopInfo { DesktopInfo {
id: de.id().to_string(), id: de.id().to_string(),
wm_class: de.startup_wm_class().map(ToString::to_string), wm_class: de.startup_wm_class().map(ToString::to_string),
icon, icon,
exec: de.exec().unwrap_or_default().to_string(), exec: de.exec().unwrap_or_default().to_string(),
name: de.name(None).unwrap_or_default().to_string(), name: de.name(None).unwrap_or_default().to_string(),
path: file_path.clone(), path: file_path.clone(),
}) }
}) })
}) { }) {
self.item_ctr += 1; self.item_ctr += 1;