ImageView: Reliably show image restored from trash

Closes #316
This commit is contained in:
Sophie Herold 2024-01-28 21:05:55 +01:00
parent f1f8ba9a88
commit 0e44037239
2 changed files with 22 additions and 9 deletions

View file

@ -667,16 +667,15 @@ impl LpWindow {
toast.connect_button_clicked(glib::clone!(@weak self as win => move |_| {
let path = path.clone();
glib::spawn_future_local(async move {
win.image_view()
.set_trash_restore(Some(gio::File::for_path(&path)));
let result = crate::util::untrash(&path).await;
match result {
Ok(()) => win.image_view().set_images_from_files(Vec::from([gio::File::for_path(&path)])),
Err(err) => {
log::error!("Failed to untrash {path:?}: {err}");
win.show_toast(
gettext("Failed to restore image from trash"),
adw::ToastPriority::High,
);
}
if let Err(err) = result {
log::error!("Failed to untrash {path:?}: {err}");
win.show_toast(
gettext("Failed to restore image from trash"),
adw::ToastPriority::High,
);
}
});
}));