ShowWidget: display a notification before removing the show.
This commit is contained in:
parent
482ed7c3c6
commit
b2c95e5a73
@ -7,6 +7,7 @@ use gtk::SettingsExt as GtkSettingsExt;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use hammond_data::{Podcast, Source};
|
||||
use hammond_data::utils::delete_show;
|
||||
|
||||
use appnotif::*;
|
||||
use headerbar::Header;
|
||||
@ -17,6 +18,7 @@ use widgets::mark_all_watched;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::time::Duration;
|
||||
use std::thread;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Action {
|
||||
@ -36,6 +38,7 @@ pub enum Action {
|
||||
HeaderBarShowUpdateIndicator,
|
||||
HeaderBarHideUpdateIndicator,
|
||||
MarkAllPlayerNotification(Arc<Podcast>),
|
||||
RemoveShow(Arc<Podcast>),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -198,6 +201,25 @@ impl App {
|
||||
// so there will be a nice animation.
|
||||
notif.show();
|
||||
}
|
||||
Ok(Action::RemoveShow(pd)) => {
|
||||
let callback = clone!(pd => move || {
|
||||
// Spawn a thread so it won't block the ui.
|
||||
thread::spawn(clone!(pd => move || {
|
||||
if let Err(err) = delete_show(&pd) {
|
||||
error!("Something went wrong trying to remove {}", pd.title());
|
||||
error!("Error: {}", err);
|
||||
}
|
||||
}));
|
||||
glib::Continue(false)
|
||||
});
|
||||
|
||||
let text = format!("Unsubscribed from {}", pd.title());
|
||||
let notif = InAppNotification::new(text.into(), callback, sender.clone());
|
||||
overlay.add_overlay(¬if.revealer);
|
||||
// We need to display the notification after the widget is added to the overlay
|
||||
// so there will be a nice animation.
|
||||
notif.show();
|
||||
}
|
||||
Err(_) => (),
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ use open;
|
||||
|
||||
use hammond_data::Podcast;
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::utils::{delete_show, replace_extra_spaces};
|
||||
use hammond_data::utils::{replace_extra_spaces};
|
||||
|
||||
use app::Action;
|
||||
use utils::get_pixbuf_from_path;
|
||||
@ -15,7 +15,6 @@ use widgets::episode::episodes_listbox;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thread;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ShowWidget {
|
||||
@ -141,13 +140,7 @@ fn on_unsub_button_clicked(
|
||||
// hack to get away without properly checking for none.
|
||||
// if pressed twice would panic.
|
||||
unsub_button.hide();
|
||||
// Spawn a thread so it won't block the ui.
|
||||
thread::spawn(move || {
|
||||
if let Err(err) = delete_show(&pd) {
|
||||
error!("Something went wrong trying to remove {}", pd.title());
|
||||
error!("Error: {}", err);
|
||||
}
|
||||
});
|
||||
sender.send(Action::RemoveShow(pd))?;
|
||||
|
||||
sender.send(Action::HeaderBarNormal)?;
|
||||
sender.send(Action::ShowShowsAnimated)?;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user