fix: initial images not loading on opening new path

This commit is contained in:
electria 2026-08-09 21:49:33 -07:00
commit 4a292a5834
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -44,6 +44,8 @@ struct State {
columns: usize,
key: usize,
error: Option<String>,
}
@ -51,9 +53,10 @@ impl State {
fn new() -> (Self, Task<Message>) {
(
Self {
columns: 3,
error: None,
images: BTreeMap::new(),
columns: 3,
key: 0,
error: None,
},
Task::done(Message::OpenPath(Some(
env::args()
@ -107,7 +110,7 @@ impl State {
.arg(path)
.spawn()
.map_err(|e| e.to_string())
.err()
.err();
}
Message::OpenPath(opt_path) => {
@ -117,6 +120,7 @@ impl State {
};
if let Some(path) = opt_path {
self.key += 1;
self.open_path(path);
}
}
@ -164,6 +168,7 @@ impl State {
|| Element::from(widget::space()),
|handle| widget::image(handle).into(),
))
.key(self.key)
.anticipate(2000)
.on_show(|_size| Message::LoadImage(path.clone()))
.on_hide(Message::UnloadImage(path.clone())),