diff --git a/src/main.rs b/src/main.rs index ab20915..871e8a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,6 @@ pub fn main() -> Result<(), iced_layershell::Error> { } struct State { - initialized: bool, current_message: String, history: Vec, input_id: Id, @@ -62,7 +61,6 @@ impl History { impl Default for State { fn default() -> Self { Self { - initialized: false, current_message: String::new(), history: Vec::new(), input_id: Id::unique(), @@ -83,27 +81,21 @@ fn namespace() -> String { String::from("Iced qalc claculator") } -fn subscription(state: &State) -> iced::Subscription { +fn subscription(_state: &State) -> iced::Subscription { use iced::event; use iced::futures::stream; - let init = if !state.initialized { - iced::Subscription::run_with("init", |_| stream::once(async { Message::Init })) - } else { - iced::Subscription::none() - }; - - iced::Subscription::batch([init, event::listen().map(Message::IcedEvent)]) + iced::Subscription::batch([ + iced::Subscription::run_with("init", |_| stream::once(async { Message::Init })), + event::listen().map(Message::IcedEvent), + ]) } fn update(state: &mut State, message: Message) -> Command { use iced::keyboard::{Event::KeyReleased, Key, key::Named}; match message { - Message::Init => { - state.initialized = true; - operation::focus(state.input_id.clone()) - } + Message::Init => operation::focus(state.input_id.clone()), Message::IcedEvent(event) => { if let Event::Keyboard(KeyReleased { key: Key::Named(Named::Escape),