ShowWidget: Hide shows from the Views when unsub is hit.
This commit is contained in:
parent
f7a7510322
commit
69e87d129a
@ -195,13 +195,19 @@ impl App {
|
||||
});
|
||||
|
||||
let text = "Marked all episodes as listened";
|
||||
let notif = InAppNotification::new(text.into(), callback, sender.clone());
|
||||
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();
|
||||
}
|
||||
Ok(Action::RemoveShow(pd)) => {
|
||||
if let Err(err) = utils::ignore_show(pd.id()) {
|
||||
error!("Could not insert {} to the ignore list.", pd.title());
|
||||
error!("Error: {}", err);
|
||||
}
|
||||
|
||||
let callback = clone!(pd => move || {
|
||||
// Spawn a thread so it won't block the ui.
|
||||
thread::spawn(clone!(pd => move || {
|
||||
@ -213,8 +219,29 @@ impl App {
|
||||
glib::Continue(false)
|
||||
});
|
||||
|
||||
let undo_callback = clone!(pd, sender => move || {
|
||||
if let Err(err) = utils::uningore_show(pd.id()) {
|
||||
error!("Could not insert {} to the ignore list.", pd.title());
|
||||
error!("Error: {}", err);
|
||||
}
|
||||
|
||||
|
||||
if let Err(err) = sender.send(Action::RefreshShowsView) {
|
||||
error!("Action channl blew up, error {}", err)
|
||||
}
|
||||
|
||||
if let Err(err) = sender.send(Action::RefreshEpisodesView) {
|
||||
error!("Action channl blew up, error {}", err)
|
||||
}
|
||||
});
|
||||
|
||||
let text = format!("Unsubscribed from {}", pd.title());
|
||||
let notif = InAppNotification::new(text.into(), callback, sender.clone());
|
||||
let notif = InAppNotification::new(
|
||||
text.into(),
|
||||
callback,
|
||||
undo_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.
|
||||
|
||||
@ -35,9 +35,15 @@ impl Default for InAppNotification {
|
||||
}
|
||||
|
||||
impl InAppNotification {
|
||||
pub fn new<F>(text: String, mut callback: F, sender: Sender<Action>) -> Self
|
||||
pub fn new<F, U>(
|
||||
text: String,
|
||||
mut callback: F,
|
||||
undo_callback: U,
|
||||
sender: Sender<Action>,
|
||||
) -> Self
|
||||
where
|
||||
F: FnMut() -> glib::Continue + 'static,
|
||||
U: Fn() + 'static,
|
||||
{
|
||||
let notif = InAppNotification::default();
|
||||
notif.text.set_text(&text);
|
||||
@ -57,14 +63,13 @@ impl InAppNotification {
|
||||
glib::source::source_remove(id);
|
||||
}
|
||||
|
||||
undo_callback();
|
||||
|
||||
// Hide the notification
|
||||
revealer.set_reveal_child(false);
|
||||
// Refresh the widget if visible
|
||||
if let Err(err) = sender.send(Action::RefreshWidgetIfVis) {
|
||||
error!(
|
||||
"Something went horribly wrong with the Action channel: {}",
|
||||
err
|
||||
)
|
||||
error!("Action channel blew up: {}", err)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user