fix: initial images not loading on opening new path
This commit is contained in:
parent
1e46fed95a
commit
4a292a5834
1 changed files with 7 additions and 2 deletions
|
|
@ -44,6 +44,8 @@ struct State {
|
||||||
|
|
||||||
columns: usize,
|
columns: usize,
|
||||||
|
|
||||||
|
key: usize,
|
||||||
|
|
||||||
error: Option<String>,
|
error: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,9 +53,10 @@ impl State {
|
||||||
fn new() -> (Self, Task<Message>) {
|
fn new() -> (Self, Task<Message>) {
|
||||||
(
|
(
|
||||||
Self {
|
Self {
|
||||||
columns: 3,
|
|
||||||
error: None,
|
|
||||||
images: BTreeMap::new(),
|
images: BTreeMap::new(),
|
||||||
|
columns: 3,
|
||||||
|
key: 0,
|
||||||
|
error: None,
|
||||||
},
|
},
|
||||||
Task::done(Message::OpenPath(Some(
|
Task::done(Message::OpenPath(Some(
|
||||||
env::args()
|
env::args()
|
||||||
|
|
@ -107,7 +110,7 @@ impl State {
|
||||||
.arg(path)
|
.arg(path)
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
.err()
|
.err();
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::OpenPath(opt_path) => {
|
Message::OpenPath(opt_path) => {
|
||||||
|
|
@ -117,6 +120,7 @@ impl State {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(path) = opt_path {
|
if let Some(path) = opt_path {
|
||||||
|
self.key += 1;
|
||||||
self.open_path(path);
|
self.open_path(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -164,6 +168,7 @@ impl State {
|
||||||
|| Element::from(widget::space()),
|
|| Element::from(widget::space()),
|
||||||
|handle| widget::image(handle).into(),
|
|handle| widget::image(handle).into(),
|
||||||
))
|
))
|
||||||
|
.key(self.key)
|
||||||
.anticipate(2000)
|
.anticipate(2000)
|
||||||
.on_show(|_size| Message::LoadImage(path.clone()))
|
.on_show(|_size| Message::LoadImage(path.clone()))
|
||||||
.on_hide(Message::UnloadImage(path.clone())),
|
.on_hide(Message::UnloadImage(path.clone())),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue