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.
This commit is contained in:
Jordan Petridis
2018-10-06 10:22:24 +03:00
parent 1e6eca307b
commit 32bd2a89a3
2 changed files with 4 additions and 5 deletions
+2 -3
View File
@@ -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<bool, DataEr
/// Check if the `episodes table contains any rows
///
/// Return true if `episodes` table is populated.
pub fn is_episodes_populated() -> Result<bool, DataError> {
pub fn is_episodes_populated(filter_show_ids: &[i32]) -> Result<bool, DataError> {
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)
}