mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
window: Refresh view on library changes
This commit is contained in:
parent
cff489f43e
commit
8ff56d2878
1 changed files with 13 additions and 4 deletions
|
|
@ -192,17 +192,26 @@ impl Window {
|
||||||
|
|
||||||
fn load_library(&self, path: impl AsRef<Path>) {
|
fn load_library(&self, path: impl AsRef<Path>) {
|
||||||
let library = Library::new(path);
|
let library = Library::new(path);
|
||||||
self.imp().player.set_library(&library);
|
|
||||||
|
|
||||||
|
library.connect_changed(clone!(
|
||||||
|
#[weak(rename_to = obj)]
|
||||||
|
self,
|
||||||
|
move |_| obj.reset_view()
|
||||||
|
));
|
||||||
|
|
||||||
|
self.imp().player.set_library(&library);
|
||||||
|
self.imp().library.replace(Some(library));
|
||||||
|
self.reset_view();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reset_view(&self) {
|
||||||
let navigation = self.imp().navigation_view.get();
|
let navigation = self.imp().navigation_view.get();
|
||||||
navigation.replace(&[SearchPage::new(
|
navigation.replace(&[SearchPage::new(
|
||||||
&navigation,
|
&navigation,
|
||||||
&library,
|
self.imp().library.borrow().as_ref().unwrap(),
|
||||||
&self.imp().player,
|
&self.imp().player,
|
||||||
LibraryQuery::default(),
|
LibraryQuery::default(),
|
||||||
)
|
)
|
||||||
.into()]);
|
.into()]);
|
||||||
|
|
||||||
self.imp().library.replace(Some(library));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue