mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 03:47:23 +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>) {
|
||||
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();
|
||||
navigation.replace(&[SearchPage::new(
|
||||
&navigation,
|
||||
&library,
|
||||
self.imp().library.borrow().as_ref().unwrap(),
|
||||
&self.imp().player,
|
||||
LibraryQuery::default(),
|
||||
)
|
||||
.into()]);
|
||||
|
||||
self.imp().library.replace(Some(library));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue