Fix search bug

This commit is contained in:
Elias Projahn 2023-10-08 00:30:30 +02:00
parent 3c83452573
commit f4a91acffa
2 changed files with 16 additions and 6 deletions

View file

@ -114,12 +114,20 @@ impl MusicusHomePage {
fn select(&self, search_entry: &MusicusSearchEntry) {
let imp = self.imp();
if let Some(person) = imp.persons.borrow().first() {
search_entry.add_tag(Tag::Person(person.clone()));
} else if let Some(ensemble) = imp.ensembles.borrow().first() {
search_entry.add_tag(Tag::Ensemble(ensemble.clone()));
} else if let Some(work) = imp.works.borrow().first() {
search_entry.add_tag(Tag::Work(work.clone()));
let (person, ensemble, work) = {
(
imp.persons.borrow().first().cloned(),
imp.ensembles.borrow().first().cloned(),
imp.works.borrow().first().cloned(),
)
};
if let Some(person) = person {
search_entry.add_tag(Tag::Person(person));
} else if let Some(ensemble) = ensemble {
search_entry.add_tag(Tag::Ensemble(ensemble));
} else if let Some(work) = work {
search_entry.add_tag(Tag::Work(work));
}
}

View file

@ -141,6 +141,7 @@ impl MusicusSearchEntry {
}
self.imp().text.set_text("");
self.emit_by_name::<()>("query-changed", &[]);
}
pub fn add_tag(&self, tag: Tag) {
@ -148,6 +149,7 @@ impl MusicusSearchEntry {
let tag = MusicusSearchTag::new(tag);
self.imp().tags_box.append(&tag);
self.imp().tags.borrow_mut().push(tag);
self.emit_by_name::<()>("query-changed", &[]);
}
pub fn query(&self) -> LibraryQuery {