From 32bd2a89a34e8e940b3b260c6be76defe11835ed Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 6 Oct 2018 10:22:24 +0300 Subject: [PATCH] Stacks: Check if there episodes insteads of shows If you added a Feed where a Show exists but it had no episodes entries, the stack would end up in a populated state, but the HomeView would be blank without widgets. This changes it so the stack state depends upon the episodes table being populated instead of the show. The downside is that if your only feed is one without episodes you can no longer navigate and interact with it. --- podcasts-data/src/dbqueries.rs | 5 ++--- podcasts-gtk/src/stacks/show.rs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/podcasts-data/src/dbqueries.rs b/podcasts-data/src/dbqueries.rs index d132d86..22e9d96 100644 --- a/podcasts-data/src/dbqueries.rs +++ b/podcasts-data/src/dbqueries.rs @@ -5,7 +5,6 @@ use diesel::prelude::*; use diesel; use diesel::dsl::exists; -use diesel::query_builder::AsQuery; use diesel::select; use database::connection; @@ -379,13 +378,13 @@ pub(crate) fn episode_exists(title_: &str, show_id_: i32) -> Result Result { +pub fn is_episodes_populated(filter_show_ids: &[i32]) -> Result { use schema::episodes::dsl::*; let db = connection(); let con = db.get()?; - select(exists(episodes.as_query())) + select(exists(episodes.filter(show_id.ne_all(filter_show_ids)))) .get_result(&con) .map_err(From::from) } diff --git a/podcasts-gtk/src/stacks/show.rs b/podcasts-gtk/src/stacks/show.rs index f57ad49..3dd621f 100644 --- a/podcasts-gtk/src/stacks/show.rs +++ b/podcasts-gtk/src/stacks/show.rs @@ -3,7 +3,7 @@ use gtk::prelude::*; use crossbeam_channel::Sender; use failure::Error; -use podcasts_data::dbqueries::is_podcasts_populated; +use podcasts_data::dbqueries::is_episodes_populated; use app::Action; use stacks::content::State; @@ -78,7 +78,7 @@ impl ShowStack { fn determine_state(&mut self) -> Result<(), Error> { let ign = get_ignored_shows()?; debug!("IGNORED SHOWS {:?}", ign); - if is_podcasts_populated(&ign)? { + if is_episodes_populated(&ign)? { self.sender.send(Action::PopulatedState); } else { self.sender.send(Action::EmptyState);