Commit ae7f65e9 authored by Jordan Petridis's avatar Jordan Petridis 🌱

InAppNotif: Switch the timer to milliseconds

This allows for more responsive updates. The implementation still
sucks though. Ideally we would pass a receiver in the callback
and have an even lower timeout_add.
parent b2d71a03
Pipeline #24933 passed with stages
in 13 minutes and 29 seconds
......@@ -312,7 +312,7 @@ impl App {
glib::Continue(false)
};
let undo_cb: Option<fn()> = None;
let notif = InAppNotification::new(&err, 6, callback, undo_cb);
let notif = InAppNotification::new(&err, 6000, callback, undo_cb);
notif.show(&self.overlay);
}
Action::ShowUpdateNotif(receiver) => {
......@@ -328,7 +328,7 @@ impl App {
};
let txt = i18n("Fetching new episodes");
let undo_cb: Option<fn()> = None;
let updater = InAppNotification::new(&txt, 1, callback, undo_cb);
let updater = InAppNotification::new(&txt, 250, callback, undo_cb);
updater.set_close_state(State::Hidden);
updater.set_spinner_state(SpinnerState::Active);
......
......@@ -48,6 +48,7 @@ impl Default for InAppNotification {
}
}
/// Timer should be in milliseconds
impl InAppNotification {
pub(crate) fn new<F, U>(
text: &str,
......@@ -64,9 +65,9 @@ impl InAppNotification {
let revealer_weak = notif.revealer.downgrade();
let mut time = 0;
let id = timeout_add_seconds(1, move || {
let id = timeout_add(250, move || {
if time < timer {
time += 1;
time += 250;
return glib::Continue(true);
};
......
......@@ -148,7 +148,7 @@ pub(crate) fn mark_all_notif(pd: Arc<Show>, sender: &Sender<Action>) -> InAppNot
let undo_callback = clone!(sender => move || sender.send(Action::RefreshWidgetIfSame(id)));
let text = i18n("Marked all episodes as listened");
InAppNotification::new(&text, 6, callback, Some(undo_callback))
InAppNotification::new(&text, 6000, callback, Some(undo_callback))
}
pub(crate) fn remove_show_notif(pd: Arc<Show>, sender: Sender<Action>) -> InAppNotification {
......@@ -184,5 +184,5 @@ pub(crate) fn remove_show_notif(pd: Arc<Show>, sender: Sender<Action>) -> InAppN
sender.send(Action::RefreshEpisodesView);
};
InAppNotification::new(&text, 6, callback, Some(undo_callback))
InAppNotification::new(&text, 6000, callback, Some(undo_callback))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment