diff --git a/org.gnome.Podcasts.json b/org.gnome.Podcasts.json index 523c303..d993b46 100644 --- a/org.gnome.Podcasts.json +++ b/org.gnome.Podcasts.json @@ -33,7 +33,7 @@ ], "env" : { "CARGO_HOME" : "/run/build/Podcasts/cargo", - "RUSTFLAGS" : "--error-format=human --remap-path-prefix =../", + "RUSTFLAGS" : "--error-format=short --remap-path-prefix =../", "RUST_BACKTRACE" : "1" } }, diff --git a/podcasts-data/src/dbqueries.rs b/podcasts-data/src/dbqueries.rs index 13d6bfb..176a9a0 100644 --- a/podcasts-data/src/dbqueries.rs +++ b/podcasts-data/src/dbqueries.rs @@ -87,13 +87,20 @@ pub(crate) fn get_downloaded_episodes() -> Result, Data .map_err(From::from) } -pub fn search_episodes(term: &str) -> Result, DataError> { +// Only searches from downloaded episodes +pub fn search_episodes(terms: Vec<&str>) -> Result, DataError> { use crate::schema::episodes::dsl::*; let db = connection(); let con = db.get()?; + let mut search_term = "".to_string(); + for term in terms { + search_term.push_str(&format!( "%{}%", term)); + } + episodes - .filter(title.like(format!("%{}%", term))) + .filter(local_uri.is_not_null()) + .filter(title.like(&search_term)) .order(epoch.desc()) .load::(&con) .map_err(From::from) diff --git a/podcasts-gtk/src/search_provider.rs b/podcasts-gtk/src/search_provider.rs index 550fc0e..f3e4299 100644 --- a/podcasts-gtk/src/search_provider.rs +++ b/podcasts-gtk/src/search_provider.rs @@ -72,21 +72,13 @@ impl SearchProvider { sender .send(Action::InitEpisode(episode.rowid())) .expect("Action channel blew up somehow"); - // TODO: Sometimes it's necessary to download the episode first. Otherwise it cannot be played. - // TODO: Greyout title state doesn't get applied. }); self.search_provider - .connect_get_initial_result_set(|terms| { - let term = terms.join(""); - Self::search(term) - }); + .connect_get_initial_result_set(|terms| Self::search(terms)); self.search_provider - .connect_get_subsearch_result_set(|_, terms| { - let term = terms.join(""); - Self::search(term) - }); + .connect_get_subsearch_result_set(|_, terms| Self::search(terms)); self.search_provider.connect_get_result_metas(|sp_ids| { let mut metas = Vec::new(); @@ -117,8 +109,8 @@ impl SearchProvider { }); } - fn search(term: String) -> Vec { - let episodes = dbqueries::search_episodes(&term) + fn search(terms: Vec<&str>) -> Vec { + let episodes = dbqueries::search_episodes(terms) .expect("Could not search for episodes (search provider)"); let mut sp_ids = Vec::new();