Models: Change the Query suffix to Model.
This is maps better to the MVC naming convention.
This commit is contained in:
parent
2d66ba918a
commit
b02b554105
@ -57,7 +57,7 @@ pub fn get_episodes() -> Result<Vec<Episode>, DataError> {
|
|||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_downloaded_episodes() -> Result<Vec<EpisodeCleanerQuery>, DataError> {
|
pub(crate) fn get_downloaded_episodes() -> Result<Vec<EpisodeCleanerModel>, DataError> {
|
||||||
use schema::episodes::dsl::*;
|
use schema::episodes::dsl::*;
|
||||||
let db = connection();
|
let db = connection();
|
||||||
let con = db.get()?;
|
let con = db.get()?;
|
||||||
@ -65,7 +65,7 @@ pub(crate) fn get_downloaded_episodes() -> Result<Vec<EpisodeCleanerQuery>, Data
|
|||||||
episodes
|
episodes
|
||||||
.select((rowid, local_uri, played))
|
.select((rowid, local_uri, played))
|
||||||
.filter(local_uri.is_not_null())
|
.filter(local_uri.is_not_null())
|
||||||
.load::<EpisodeCleanerQuery>(&con)
|
.load::<EpisodeCleanerModel>(&con)
|
||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ pub(crate) fn get_downloaded_episodes() -> Result<Vec<EpisodeCleanerQuery>, Data
|
|||||||
// .map_err(From::from)
|
// .map_err(From::from)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub(crate) fn get_played_cleaner_episodes() -> Result<Vec<EpisodeCleanerQuery>, DataError> {
|
pub(crate) fn get_played_cleaner_episodes() -> Result<Vec<EpisodeCleanerModel>, DataError> {
|
||||||
use schema::episodes::dsl::*;
|
use schema::episodes::dsl::*;
|
||||||
let db = connection();
|
let db = connection();
|
||||||
let con = db.get()?;
|
let con = db.get()?;
|
||||||
@ -88,7 +88,7 @@ pub(crate) fn get_played_cleaner_episodes() -> Result<Vec<EpisodeCleanerQuery>,
|
|||||||
episodes
|
episodes
|
||||||
.select((rowid, local_uri, played))
|
.select((rowid, local_uri, played))
|
||||||
.filter(played.is_not_null())
|
.filter(played.is_not_null())
|
||||||
.load::<EpisodeCleanerQuery>(&con)
|
.load::<EpisodeCleanerModel>(&con)
|
||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ pub fn get_episode_from_rowid(ep_id: i32) -> Result<Episode, DataError> {
|
|||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_episode_widget_from_rowid(ep_id: i32) -> Result<EpisodeWidgetQuery, DataError> {
|
pub fn get_episode_widget_from_rowid(ep_id: i32) -> Result<EpisodeWidgetModel, DataError> {
|
||||||
use schema::episodes::dsl::*;
|
use schema::episodes::dsl::*;
|
||||||
let db = connection();
|
let db = connection();
|
||||||
let con = db.get()?;
|
let con = db.get()?;
|
||||||
@ -113,7 +113,7 @@ pub fn get_episode_widget_from_rowid(ep_id: i32) -> Result<EpisodeWidgetQuery, D
|
|||||||
rowid, title, uri, local_uri, epoch, length, duration, played, show_id,
|
rowid, title, uri, local_uri, epoch, length, duration, played, show_id,
|
||||||
))
|
))
|
||||||
.filter(rowid.eq(ep_id))
|
.filter(rowid.eq(ep_id))
|
||||||
.get_result::<EpisodeWidgetQuery>(&con)
|
.get_result::<EpisodeWidgetModel>(&con)
|
||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ pub fn get_episode_local_uri_from_id(ep_id: i32) -> Result<Option<String>, DataE
|
|||||||
pub fn get_episodes_widgets_filter_limit(
|
pub fn get_episodes_widgets_filter_limit(
|
||||||
filter_ids: &[i32],
|
filter_ids: &[i32],
|
||||||
limit: u32,
|
limit: u32,
|
||||||
) -> Result<Vec<EpisodeWidgetQuery>, DataError> {
|
) -> Result<Vec<EpisodeWidgetModel>, DataError> {
|
||||||
use schema::episodes::dsl::*;
|
use schema::episodes::dsl::*;
|
||||||
let db = connection();
|
let db = connection();
|
||||||
let con = db.get()?;
|
let con = db.get()?;
|
||||||
@ -145,7 +145,7 @@ pub fn get_episodes_widgets_filter_limit(
|
|||||||
.order(epoch.desc())
|
.order(epoch.desc())
|
||||||
.filter(show_id.ne_all(filter_ids))
|
.filter(show_id.ne_all(filter_ids))
|
||||||
.limit(i64::from(limit))
|
.limit(i64::from(limit))
|
||||||
.load::<EpisodeWidgetQuery>(&con)
|
.load::<EpisodeWidgetModel>(&con)
|
||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ pub fn get_podcast_from_id(pid: i32) -> Result<Show, DataError> {
|
|||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_podcast_cover_from_id(pid: i32) -> Result<ShowCoverQuery, DataError> {
|
pub fn get_podcast_cover_from_id(pid: i32) -> Result<ShowCoverModel, DataError> {
|
||||||
use schema::shows::dsl::*;
|
use schema::shows::dsl::*;
|
||||||
let db = connection();
|
let db = connection();
|
||||||
let con = db.get()?;
|
let con = db.get()?;
|
||||||
@ -168,7 +168,7 @@ pub fn get_podcast_cover_from_id(pid: i32) -> Result<ShowCoverQuery, DataError>
|
|||||||
shows
|
shows
|
||||||
.select((id, title, image_uri))
|
.select((id, title, image_uri))
|
||||||
.filter(id.eq(pid))
|
.filter(id.eq(pid))
|
||||||
.get_result::<ShowCoverQuery>(&con)
|
.get_result::<ShowCoverModel>(&con)
|
||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ pub fn get_pd_episodes_count(parent: &Show) -> Result<i64, DataError> {
|
|||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pd_episodeswidgets(parent: &Show) -> Result<Vec<EpisodeWidgetQuery>, DataError> {
|
pub fn get_pd_episodeswidgets(parent: &Show) -> Result<Vec<EpisodeWidgetModel>, DataError> {
|
||||||
use schema::episodes::dsl::*;
|
use schema::episodes::dsl::*;
|
||||||
let db = connection();
|
let db = connection();
|
||||||
let con = db.get()?;
|
let con = db.get()?;
|
||||||
@ -205,7 +205,7 @@ pub fn get_pd_episodeswidgets(parent: &Show) -> Result<Vec<EpisodeWidgetQuery>,
|
|||||||
.select(columns)
|
.select(columns)
|
||||||
.filter(show_id.eq(parent.id()))
|
.filter(show_id.eq(parent.id()))
|
||||||
.order(epoch.desc())
|
.order(epoch.desc())
|
||||||
.load::<EpisodeWidgetQuery>(&con)
|
.load::<EpisodeWidgetModel>(&con)
|
||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,7 @@ pub mod utils;
|
|||||||
|
|
||||||
pub use feed::{Feed, FeedBuilder};
|
pub use feed::{Feed, FeedBuilder};
|
||||||
pub use models::Save;
|
pub use models::Save;
|
||||||
pub use models::{Episode, EpisodeWidgetQuery, Show, ShowCoverQuery, Source};
|
pub use models::{Episode, EpisodeWidgetModel, Show, ShowCoverModel, Source};
|
||||||
|
|
||||||
// Set the user agent, See #53 for more
|
// Set the user agent, See #53 for more
|
||||||
// Keep this in sync with Tor-browser releases
|
// Keep this in sync with Tor-browser releases
|
||||||
|
|||||||
@ -171,7 +171,7 @@ impl Episode {
|
|||||||
#[primary_key(title, show_id)]
|
#[primary_key(title, show_id)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
/// Diesel Model to be used for constructing `EpisodeWidgets`.
|
/// Diesel Model to be used for constructing `EpisodeWidgets`.
|
||||||
pub struct EpisodeWidgetQuery {
|
pub struct EpisodeWidgetModel {
|
||||||
rowid: i32,
|
rowid: i32,
|
||||||
title: String,
|
title: String,
|
||||||
uri: Option<String>,
|
uri: Option<String>,
|
||||||
@ -183,9 +183,9 @@ pub struct EpisodeWidgetQuery {
|
|||||||
show_id: i32,
|
show_id: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Episode> for EpisodeWidgetQuery {
|
impl From<Episode> for EpisodeWidgetModel {
|
||||||
fn from(e: Episode) -> EpisodeWidgetQuery {
|
fn from(e: Episode) -> EpisodeWidgetModel {
|
||||||
EpisodeWidgetQuery {
|
EpisodeWidgetModel {
|
||||||
rowid: e.rowid,
|
rowid: e.rowid,
|
||||||
title: e.title,
|
title: e.title,
|
||||||
uri: e.uri,
|
uri: e.uri,
|
||||||
@ -199,7 +199,7 @@ impl From<Episode> for EpisodeWidgetQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Save<usize> for EpisodeWidgetQuery {
|
impl Save<usize> for EpisodeWidgetModel {
|
||||||
type Error = DataError;
|
type Error = DataError;
|
||||||
|
|
||||||
/// Helper method to easily save/"sync" current state of self to the
|
/// Helper method to easily save/"sync" current state of self to the
|
||||||
@ -217,7 +217,7 @@ impl Save<usize> for EpisodeWidgetQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EpisodeWidgetQuery {
|
impl EpisodeWidgetModel {
|
||||||
/// Get the value of the sqlite's `ROW_ID`
|
/// Get the value of the sqlite's `ROW_ID`
|
||||||
pub fn rowid(&self) -> i32 {
|
pub fn rowid(&self) -> i32 {
|
||||||
self.rowid
|
self.rowid
|
||||||
@ -311,13 +311,13 @@ impl EpisodeWidgetQuery {
|
|||||||
#[primary_key(title, show_id)]
|
#[primary_key(title, show_id)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
/// Diesel Model to be used internal with the `utils::checkup` function.
|
/// Diesel Model to be used internal with the `utils::checkup` function.
|
||||||
pub struct EpisodeCleanerQuery {
|
pub struct EpisodeCleanerModel {
|
||||||
rowid: i32,
|
rowid: i32,
|
||||||
local_uri: Option<String>,
|
local_uri: Option<String>,
|
||||||
played: Option<i32>,
|
played: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Save<usize> for EpisodeCleanerQuery {
|
impl Save<usize> for EpisodeCleanerModel {
|
||||||
type Error = DataError;
|
type Error = DataError;
|
||||||
|
|
||||||
/// Helper method to easily save/"sync" current state of self to the
|
/// Helper method to easily save/"sync" current state of self to the
|
||||||
@ -335,9 +335,9 @@ impl Save<usize> for EpisodeCleanerQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Episode> for EpisodeCleanerQuery {
|
impl From<Episode> for EpisodeCleanerModel {
|
||||||
fn from(e: Episode) -> EpisodeCleanerQuery {
|
fn from(e: Episode) -> EpisodeCleanerModel {
|
||||||
EpisodeCleanerQuery {
|
EpisodeCleanerModel {
|
||||||
rowid: e.rowid(),
|
rowid: e.rowid(),
|
||||||
local_uri: e.local_uri,
|
local_uri: e.local_uri,
|
||||||
played: e.played,
|
played: e.played,
|
||||||
@ -345,7 +345,7 @@ impl From<Episode> for EpisodeCleanerQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EpisodeCleanerQuery {
|
impl EpisodeCleanerModel {
|
||||||
/// Get the value of the sqlite's `ROW_ID`
|
/// Get the value of the sqlite's `ROW_ID`
|
||||||
pub fn rowid(&self) -> i32 {
|
pub fn rowid(&self) -> i32 {
|
||||||
self.rowid
|
self.rowid
|
||||||
|
|||||||
@ -9,7 +9,7 @@ mod source;
|
|||||||
// use futures::prelude::*;
|
// use futures::prelude::*;
|
||||||
// use futures::future::*;
|
// use futures::future::*;
|
||||||
|
|
||||||
pub(crate) use self::episode::EpisodeCleanerQuery;
|
pub(crate) use self::episode::EpisodeCleanerModel;
|
||||||
pub(crate) use self::new_episode::{NewEpisode, NewEpisodeMinimal};
|
pub(crate) use self::new_episode::{NewEpisode, NewEpisodeMinimal};
|
||||||
pub(crate) use self::new_show::NewShow;
|
pub(crate) use self::new_show::NewShow;
|
||||||
pub(crate) use self::new_source::NewSource;
|
pub(crate) use self::new_source::NewSource;
|
||||||
@ -19,8 +19,8 @@ pub(crate) use self::new_episode::NewEpisodeBuilder;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) use self::new_show::NewShowBuilder;
|
pub(crate) use self::new_show::NewShowBuilder;
|
||||||
|
|
||||||
pub use self::episode::{Episode, EpisodeMinimal, EpisodeWidgetQuery};
|
pub use self::episode::{Episode, EpisodeMinimal, EpisodeWidgetModel};
|
||||||
pub use self::show::{Show, ShowCoverQuery};
|
pub use self::show::{Show, ShowCoverModel};
|
||||||
pub use self::source::Source;
|
pub use self::source::Source;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|||||||
@ -87,15 +87,15 @@ impl Show {
|
|||||||
#[derive(Queryable, Debug, Clone)]
|
#[derive(Queryable, Debug, Clone)]
|
||||||
/// Diesel Model of the Show cover query.
|
/// Diesel Model of the Show cover query.
|
||||||
/// Used for fetching information about a Show's cover.
|
/// Used for fetching information about a Show's cover.
|
||||||
pub struct ShowCoverQuery {
|
pub struct ShowCoverModel {
|
||||||
id: i32,
|
id: i32,
|
||||||
title: String,
|
title: String,
|
||||||
image_uri: Option<String>,
|
image_uri: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Show> for ShowCoverQuery {
|
impl From<Show> for ShowCoverModel {
|
||||||
fn from(p: Show) -> ShowCoverQuery {
|
fn from(p: Show) -> ShowCoverModel {
|
||||||
ShowCoverQuery {
|
ShowCoverModel {
|
||||||
id: p.id(),
|
id: p.id(),
|
||||||
title: p.title,
|
title: p.title,
|
||||||
image_uri: p.image_uri,
|
image_uri: p.image_uri,
|
||||||
@ -103,7 +103,7 @@ impl From<Show> for ShowCoverQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShowCoverQuery {
|
impl ShowCoverModel {
|
||||||
/// Get the Feed `id`.
|
/// Get the Feed `id`.
|
||||||
pub fn id(&self) -> i32 {
|
pub fn id(&self) -> i32 {
|
||||||
self.id
|
self.id
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use url::{Position, Url};
|
|||||||
|
|
||||||
use dbqueries;
|
use dbqueries;
|
||||||
use errors::DataError;
|
use errors::DataError;
|
||||||
use models::{EpisodeCleanerQuery, Save, Show};
|
use models::{EpisodeCleanerModel, Save, Show};
|
||||||
use xdg_dirs::DL_DIR;
|
use xdg_dirs::DL_DIR;
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@ -59,7 +59,7 @@ fn played_cleaner(cleanup_date: DateTime<Utc>) -> Result<(), DataError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check `ep.local_uri` field and delete the file it points to.
|
/// Check `ep.local_uri` field and delete the file it points to.
|
||||||
fn delete_local_content(ep: &mut EpisodeCleanerQuery) -> Result<(), DataError> {
|
fn delete_local_content(ep: &mut EpisodeCleanerModel) -> Result<(), DataError> {
|
||||||
if ep.local_uri().is_some() {
|
if ep.local_uri().is_some() {
|
||||||
let uri = ep.local_uri().unwrap().to_owned();
|
let uri = ep.local_uri().unwrap().to_owned();
|
||||||
if Path::new(&uri).exists() {
|
if Path::new(&uri).exists() {
|
||||||
@ -230,7 +230,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_download_cleaner() {
|
fn test_download_cleaner() {
|
||||||
let _tmp_dir = helper_db();
|
let _tmp_dir = helper_db();
|
||||||
let mut episode: EpisodeCleanerQuery =
|
let mut episode: EpisodeCleanerModel =
|
||||||
dbqueries::get_episode_from_pk("foo_bar", 0).unwrap().into();
|
dbqueries::get_episode_from_pk("foo_bar", 0).unwrap().into();
|
||||||
|
|
||||||
let valid_path = episode.local_uri().unwrap().to_owned();
|
let valid_path = episode.local_uri().unwrap().to_owned();
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use std::path::Path;
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use hammond_data::xdg_dirs::HAMMOND_CACHE;
|
use hammond_data::xdg_dirs::HAMMOND_CACHE;
|
||||||
use hammond_data::{EpisodeWidgetQuery, Save, ShowCoverQuery};
|
use hammond_data::{EpisodeWidgetModel, Save, ShowCoverModel};
|
||||||
|
|
||||||
// use failure::Error;
|
// use failure::Error;
|
||||||
use errors::DownloadError;
|
use errors::DownloadError;
|
||||||
@ -161,7 +161,7 @@ fn save_io(
|
|||||||
|
|
||||||
// TODO: Refactor
|
// TODO: Refactor
|
||||||
pub fn get_episode(
|
pub fn get_episode(
|
||||||
ep: &mut EpisodeWidgetQuery,
|
ep: &mut EpisodeWidgetModel,
|
||||||
download_folder: &str,
|
download_folder: &str,
|
||||||
progress: Option<Arc<Mutex<DownloadProgress>>>,
|
progress: Option<Arc<Mutex<DownloadProgress>>>,
|
||||||
) -> Result<(), DownloadError> {
|
) -> Result<(), DownloadError> {
|
||||||
@ -196,7 +196,7 @@ pub fn get_episode(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cache_image(pd: &ShowCoverQuery) -> Result<String, DownloadError> {
|
pub fn cache_image(pd: &ShowCoverModel) -> Result<String, DownloadError> {
|
||||||
let url = pd
|
let url = pd
|
||||||
.image_uri()
|
.image_uri()
|
||||||
.ok_or_else(|| DownloadError::NoImageLocation)?
|
.ok_or_else(|| DownloadError::NoImageLocation)?
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use open;
|
|||||||
|
|
||||||
use hammond_data::dbqueries;
|
use hammond_data::dbqueries;
|
||||||
use hammond_data::utils::get_download_folder;
|
use hammond_data::utils::get_download_folder;
|
||||||
use hammond_data::EpisodeWidgetQuery;
|
use hammond_data::EpisodeWidgetModel;
|
||||||
|
|
||||||
use app::Action;
|
use app::Action;
|
||||||
use manager;
|
use manager;
|
||||||
@ -68,7 +68,7 @@ struct Buttons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl InfoLabels {
|
impl InfoLabels {
|
||||||
fn init(&self, episode: &EpisodeWidgetQuery) {
|
fn init(&self, episode: &EpisodeWidgetModel) {
|
||||||
// Set the title label state.
|
// Set the title label state.
|
||||||
self.set_title(episode);
|
self.set_title(episode);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ impl InfoLabels {
|
|||||||
self.set_size(episode.length())
|
self.set_size(episode.length())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_title(&self, episode: &EpisodeWidgetQuery) {
|
fn set_title(&self, episode: &EpisodeWidgetModel) {
|
||||||
self.title.set_text(episode.title());
|
self.title.set_text(episode.title());
|
||||||
|
|
||||||
if episode.played().is_some() {
|
if episode.played().is_some() {
|
||||||
@ -206,7 +206,7 @@ impl Default for EpisodeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EpisodeWidget {
|
impl EpisodeWidget {
|
||||||
pub fn new(episode: &EpisodeWidgetQuery, sender: &Sender<Action>) -> Rc<Self> {
|
pub fn new(episode: &EpisodeWidgetModel, sender: &Sender<Action>) -> Rc<Self> {
|
||||||
let widget = Rc::new(Self::default());
|
let widget = Rc::new(Self::default());
|
||||||
widget.info.init(episode);
|
widget.info.init(episode);
|
||||||
Self::determine_buttons_state(&widget, episode, sender)
|
Self::determine_buttons_state(&widget, episode, sender)
|
||||||
@ -297,7 +297,7 @@ impl EpisodeWidget {
|
|||||||
/// -------------------
|
/// -------------------
|
||||||
fn determine_buttons_state(
|
fn determine_buttons_state(
|
||||||
widget: &Rc<Self>,
|
widget: &Rc<Self>,
|
||||||
episode: &EpisodeWidgetQuery,
|
episode: &EpisodeWidgetModel,
|
||||||
sender: &Sender<Action>,
|
sender: &Sender<Action>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// Reset the buttons state no matter the glade file.
|
// Reset the buttons state no matter the glade file.
|
||||||
@ -428,7 +428,7 @@ impl EpisodeWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_download_clicked(ep: &EpisodeWidgetQuery, sender: &Sender<Action>) -> Result<(), Error> {
|
fn on_download_clicked(ep: &EpisodeWidgetModel, sender: &Sender<Action>) -> Result<(), Error> {
|
||||||
let pd = dbqueries::get_podcast_from_id(ep.show_id())?;
|
let pd = dbqueries::get_podcast_from_id(ep.show_id())?;
|
||||||
let download_fold = get_download_folder(&pd.title())?;
|
let download_fold = get_download_folder(&pd.title())?;
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ fn on_download_clicked(ep: &EpisodeWidgetQuery, sender: &Sender<Action>) -> Resu
|
|||||||
|
|
||||||
fn on_play_bttn_clicked(
|
fn on_play_bttn_clicked(
|
||||||
widget: &Rc<EpisodeWidget>,
|
widget: &Rc<EpisodeWidget>,
|
||||||
episode: &mut EpisodeWidgetQuery,
|
episode: &mut EpisodeWidgetModel,
|
||||||
sender: &Sender<Action>,
|
sender: &Sender<Action>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// Mark played
|
// Mark played
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use gtk::prelude::*;
|
|||||||
|
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use hammond_data::dbqueries;
|
use hammond_data::dbqueries;
|
||||||
use hammond_data::EpisodeWidgetQuery;
|
use hammond_data::EpisodeWidgetModel;
|
||||||
use send_cell::SendCell;
|
use send_cell::SendCell;
|
||||||
|
|
||||||
use app::Action;
|
use app::Action;
|
||||||
@ -93,7 +93,7 @@ impl HomeView {
|
|||||||
let now_utc = Utc::now();
|
let now_utc = Utc::now();
|
||||||
|
|
||||||
let view_ = view.clone();
|
let view_ = view.clone();
|
||||||
let func = move |ep: EpisodeWidgetQuery| {
|
let func = move |ep: EpisodeWidgetModel| {
|
||||||
let epoch = ep.epoch();
|
let epoch = ep.epoch();
|
||||||
let widget = HomeEpisode::new(&ep, &sender);
|
let widget = HomeEpisode::new(&ep, &sender);
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ impl Default for HomeEpisode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl HomeEpisode {
|
impl HomeEpisode {
|
||||||
fn new(episode: &EpisodeWidgetQuery, sender: &Sender<Action>) -> HomeEpisode {
|
fn new(episode: &EpisodeWidgetModel, sender: &Sender<Action>) -> HomeEpisode {
|
||||||
let builder =
|
let builder =
|
||||||
gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/episodes_view_widget.ui");
|
gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/episodes_view_widget.ui");
|
||||||
let container: gtk::Box = builder.get_object("container").unwrap();
|
let container: gtk::Box = builder.get_object("container").unwrap();
|
||||||
|
|||||||
@ -14,7 +14,7 @@ use failure::Error;
|
|||||||
use send_cell::SendCell;
|
use send_cell::SendCell;
|
||||||
|
|
||||||
use hammond_data::{dbqueries, USER_AGENT};
|
use hammond_data::{dbqueries, USER_AGENT};
|
||||||
use hammond_data::{EpisodeWidgetQuery, ShowCoverQuery};
|
use hammond_data::{EpisodeWidgetModel, ShowCoverModel};
|
||||||
|
|
||||||
use app::Action;
|
use app::Action;
|
||||||
use utils::set_image_from_path;
|
use utils::set_image_from_path;
|
||||||
@ -49,23 +49,23 @@ struct PlayerInfo {
|
|||||||
|
|
||||||
impl PlayerInfo {
|
impl PlayerInfo {
|
||||||
// FIXME: create a Diesel Model of the joined episode and podcast query instead
|
// FIXME: create a Diesel Model of the joined episode and podcast query instead
|
||||||
fn init(&self, episode: &EpisodeWidgetQuery, podcast: &ShowCoverQuery) {
|
fn init(&self, episode: &EpisodeWidgetModel, podcast: &ShowCoverModel) {
|
||||||
self.set_cover_image(podcast);
|
self.set_cover_image(podcast);
|
||||||
self.set_show_title(podcast);
|
self.set_show_title(podcast);
|
||||||
self.set_episode_title(episode);
|
self.set_episode_title(episode);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_episode_title(&self, episode: &EpisodeWidgetQuery) {
|
fn set_episode_title(&self, episode: &EpisodeWidgetModel) {
|
||||||
self.episode.set_text(episode.title());
|
self.episode.set_text(episode.title());
|
||||||
self.episode.set_tooltip_text(episode.title());
|
self.episode.set_tooltip_text(episode.title());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_show_title(&self, show: &ShowCoverQuery) {
|
fn set_show_title(&self, show: &ShowCoverModel) {
|
||||||
self.show.set_text(show.title());
|
self.show.set_text(show.title());
|
||||||
self.show.set_tooltip_text(show.title());
|
self.show.set_tooltip_text(show.title());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_cover_image(&self, show: &ShowCoverQuery) {
|
fn set_cover_image(&self, show: &ShowCoverModel) {
|
||||||
set_image_from_path(&self.cover, show.id(), 34)
|
set_image_from_path(&self.cover, show.id(), 34)
|
||||||
.map_err(|err| error!("Player Cover: {}", err))
|
.map_err(|err| error!("Player Cover: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user