only countdown when there's a confirm popup

Co-authored-by: Ashley Wulber <48420062+wash2@users.noreply.github.com>
This commit is contained in:
PixelDoted 2023-10-31 11:51:38 -05:00 committed by Ashley Wulber
parent 2882286de6
commit 2c9470bdd7

View file

@ -109,18 +109,18 @@ impl cosmic::Application for Power {
} }
fn subscription(&self) -> Subscription<Message> { fn subscription(&self) -> Subscription<Message> {
Subscription::batch(vec![ let mut subscriptions = Vec::with_capacity(2);
events_with(|e, _status| match e { subscriptions.push(events_with(|e, _status| match e {
cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland( cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Layer(LayerEvent::Unfocused, ..), wayland::Event::Layer(LayerEvent::Unfocused, ..),
)) => Some(Message::Cancel), )) => Some(Message::Cancel),
// cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland( _ => None,
// wayland::Event::Seat(wayland::SeatEvent::Leave, _), }));
// )) => Some(Message::Cancel), if self.action_to_confirm.is_some() {
_ => None, subscriptions
}), .push(time::every(Duration::from_millis(1000)).map(|_| Message::Countdown));
time::every(Duration::from_millis(1000)).map(|_| Message::Countdown), }
]) Subscription::batch(subscriptions)
} }
fn update(&mut self, message: Message) -> Command<Message> { fn update(&mut self, message: Message) -> Command<Message> {