refactor: use newer helper method in State::new

this should keep it from printing "no image to allocate"
each time when started without an argument
This commit is contained in:
electria 2026-07-30 20:26:21 -07:00
commit 9bdd556c9d
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -30,14 +30,14 @@ impl State {
fn new() -> (Self, Task<Message>) {
let mut state = State::default();
state.error = env::args().nth(1).and_then(|path| {
utils::load_image(path)
.map(|image| state.image = Some(image))
.err()
});
let allocate_image = state.allocate_image();
if let Some(path) = env::args().nth(1) {
match state.load_image(path) {
Err(e) => state.error = Some(e),
Ok(task) => return (state, task),
}
}
(state, allocate_image)
(state, Task::none())
}
fn view(&self) -> Element<'_, Message, Theme, Renderer> {
let mut main = Vec::new();