InAppNotif: Pass revealer to the callback
Let the callback handle if/when the visibility of the notification
This commit is contained in:
parent
25195c972c
commit
911dcbac9f
@ -305,7 +305,10 @@ impl App {
|
|||||||
}
|
}
|
||||||
Action::ErrorNotification(err) => {
|
Action::ErrorNotification(err) => {
|
||||||
error!("An error notification was triggered: {}", err);
|
error!("An error notification was triggered: {}", err);
|
||||||
let callback = || glib::Continue(false);
|
let callback = |revealer: gtk::Revealer| {
|
||||||
|
revealer.set_reveal_child(false);
|
||||||
|
glib::Continue(false)
|
||||||
|
};
|
||||||
let undo_cb: Option<fn()> = None;
|
let undo_cb: Option<fn()> = None;
|
||||||
let notif = InAppNotification::new(&err, 6, callback, undo_cb);
|
let notif = InAppNotification::new(&err, 6, callback, undo_cb);
|
||||||
notif.show(&self.overlay);
|
notif.show(&self.overlay);
|
||||||
|
|||||||
@ -46,7 +46,7 @@ impl InAppNotification {
|
|||||||
undo_callback: Option<U>,
|
undo_callback: Option<U>,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
F: FnMut() -> glib::Continue + 'static,
|
F: FnMut(gtk::Revealer) -> glib::Continue + 'static,
|
||||||
U: Fn() + 'static,
|
U: Fn() + 'static,
|
||||||
{
|
{
|
||||||
let notif = InAppNotification::default();
|
let notif = InAppNotification::default();
|
||||||
@ -65,8 +65,7 @@ impl InAppNotification {
|
|||||||
None => return glib::Continue(false),
|
None => return glib::Continue(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
revealer.set_reveal_child(false);
|
callback(revealer)
|
||||||
callback()
|
|
||||||
});
|
});
|
||||||
let id = Rc::new(RefCell::new(Some(id)));
|
let id = Rc::new(RefCell::new(Some(id)));
|
||||||
|
|
||||||
|
|||||||
@ -137,11 +137,14 @@ fn mark_all_watched(pd: &Show, sender: &Sender<Action>) -> Result<(), Error> {
|
|||||||
|
|
||||||
pub(crate) fn mark_all_notif(pd: Arc<Show>, sender: &Sender<Action>) -> InAppNotification {
|
pub(crate) fn mark_all_notif(pd: Arc<Show>, sender: &Sender<Action>) -> InAppNotification {
|
||||||
let id = pd.id();
|
let id = pd.id();
|
||||||
let callback = clone!(sender => move || {
|
let sender_ = sender.clone();
|
||||||
let res = mark_all_watched(&pd, &sender);
|
let callback = move |revealer: gtk::Revealer| {
|
||||||
|
let res = mark_all_watched(&pd, &sender_);
|
||||||
debug_assert!(res.is_ok());
|
debug_assert!(res.is_ok());
|
||||||
|
|
||||||
|
revealer.set_reveal_child(false);
|
||||||
glib::Continue(false)
|
glib::Continue(false)
|
||||||
});
|
};
|
||||||
|
|
||||||
let undo_callback = clone!(sender => move || sender.send(Action::RefreshWidgetIfSame(id)));
|
let undo_callback = clone!(sender => move || sender.send(Action::RefreshWidgetIfSame(id)));
|
||||||
let text = i18n("Marked all episodes as listened");
|
let text = i18n("Marked all episodes as listened");
|
||||||
@ -154,21 +157,25 @@ pub(crate) fn remove_show_notif(pd: Arc<Show>, sender: Sender<Action>) -> InAppN
|
|||||||
let res = utils::ignore_show(pd.id());
|
let res = utils::ignore_show(pd.id());
|
||||||
debug_assert!(res.is_ok());
|
debug_assert!(res.is_ok());
|
||||||
|
|
||||||
let callback = clone!(pd, sender => move || {
|
let sender_ = sender.clone();
|
||||||
let res = utils::uningore_show(pd.id());
|
let pd_ = pd.clone();
|
||||||
|
let callback = move |revealer: gtk::Revealer| {
|
||||||
|
let res = utils::uningore_show(pd_.id());
|
||||||
debug_assert!(res.is_ok());
|
debug_assert!(res.is_ok());
|
||||||
|
|
||||||
// Spawn a thread so it won't block the ui.
|
// Spawn a thread so it won't block the ui.
|
||||||
rayon::spawn(clone!(pd, sender => move || {
|
rayon::spawn(clone!(pd_, sender_ => move || {
|
||||||
delete_show(&pd)
|
delete_show(&pd_)
|
||||||
.map_err(|err| error!("Error: {}", err))
|
.map_err(|err| error!("Error: {}", err))
|
||||||
.map_err(|_| error!("Failed to delete {}", pd.title()))
|
.map_err(|_| error!("Failed to delete {}", pd_.title()))
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
sender.send(Action::RefreshEpisodesView);
|
sender_.send(Action::RefreshEpisodesView);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
revealer.set_reveal_child(false);
|
||||||
glib::Continue(false)
|
glib::Continue(false)
|
||||||
});
|
};
|
||||||
|
|
||||||
let undo_callback = move || {
|
let undo_callback = move || {
|
||||||
let res = utils::uningore_show(pd.id());
|
let res = utils::uningore_show(pd.id());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user