h-gtk: Take into account the ignored_shows when detemening if podcast table is empty.
If you've had one show and pressed unsub, instead of going to an empty view, it would stay to populated since it the db records where still there.
This commit is contained in:
parent
72a6832571
commit
dc5ff9d809
@ -363,13 +363,13 @@ pub fn is_episodes_populated() -> Result<bool, DataError> {
|
||||
/// Check if the `podcast` table contains any rows
|
||||
///
|
||||
/// Return true if `podcast table is populated.
|
||||
pub fn is_podcasts_populated() -> Result<bool, DataError> {
|
||||
pub fn is_podcasts_populated(filter_ids: &[i32]) -> Result<bool, DataError> {
|
||||
use schema::podcast::dsl::*;
|
||||
|
||||
let db = connection();
|
||||
let con = db.get()?;
|
||||
|
||||
select(exists(podcast.as_query()))
|
||||
select(exists(podcast.filter(id.ne_all(filter_ids))))
|
||||
.get_result(&con)
|
||||
.map_err(From::from)
|
||||
}
|
||||
|
||||
@ -63,9 +63,8 @@ impl Content {
|
||||
}
|
||||
|
||||
pub fn update_shows_view(&self) {
|
||||
let pop = self.shows.borrow().populated();
|
||||
pop.borrow_mut()
|
||||
.update_shows()
|
||||
self.shows.borrow_mut()
|
||||
.update()
|
||||
.map_err(|err| error!("Failed to update ShowsView: {}", err))
|
||||
.ok();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ use hammond_data::dbqueries::is_podcasts_populated;
|
||||
|
||||
use app::Action;
|
||||
use stacks::PopulatedStack;
|
||||
use utils::get_ignored_shows;
|
||||
use widgets::EmptyView;
|
||||
|
||||
use std::cell::RefCell;
|
||||
@ -82,7 +83,9 @@ impl ShowStack {
|
||||
fn determine_state(&mut self) -> Result<(), Error> {
|
||||
use self::ShowState::*;
|
||||
|
||||
if is_podcasts_populated()? {
|
||||
let ign = get_ignored_shows()?;
|
||||
debug!("IGNORED SHOWS {:?}", ign);
|
||||
if is_podcasts_populated(&ign)? {
|
||||
self.switch_visible(Populated);
|
||||
} else {
|
||||
self.switch_visible(Empty);
|
||||
|
||||
@ -303,18 +303,20 @@ pub fn remove_show_notif(pd: Arc<Podcast>, sender: Sender<Action>) -> InAppNotif
|
||||
.map_err(|_| error!("Could not insert {} to the ignore list.", pd.title()))
|
||||
.ok();
|
||||
|
||||
let callback = clone!(pd => move || {
|
||||
let callback = clone!(pd, sender => move || {
|
||||
utils::uningore_show(pd.id())
|
||||
.map_err(|err| error!("Error: {}", err))
|
||||
.map_err(|_| error!("Could not remove {} from the ignore list.", pd.title()))
|
||||
.ok();
|
||||
|
||||
// Spawn a thread so it won't block the ui.
|
||||
rayon::spawn(clone!(pd => move || {
|
||||
rayon::spawn(clone!(pd, sender => move || {
|
||||
delete_show(&pd)
|
||||
.map_err(|err| error!("Error: {}", err))
|
||||
.map_err(|_| error!("Failed to delete {}", pd.title()))
|
||||
.ok();
|
||||
|
||||
sender.send(Action::RefreshEpisodesView).ok();
|
||||
}));
|
||||
glib::Continue(false)
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user