Compare commits
No commits in common. "b8cb3b1673b20037063c3ea44fd8da7dde99a61f" and "94c6b96559a1bf756c844e8e28b220b8686d0366" have entirely different histories.
b8cb3b1673
...
94c6b96559
6 changed files with 4 additions and 107 deletions
|
|
@ -72,15 +72,6 @@ impl DataManager {
|
||||||
.set_film_watched_status(uuid, watched)
|
.set_film_watched_status(uuid, watched)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_film_downloaded_status(
|
|
||||||
uuid: &str,
|
|
||||||
downloaded: bool,
|
|
||||||
) -> Result<(), DataManagerError> {
|
|
||||||
sqlite_manager!()
|
|
||||||
.set_film_downloaded_status(uuid, downloaded)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,10 @@ impl SqliteManager {
|
||||||
connection
|
connection
|
||||||
.prepare(
|
.prepare(
|
||||||
"
|
"
|
||||||
select films.uuid, films.name, films.original_name, films.release_date,
|
select films.uuid, films.name, films.original_name, films.release_date, films.runtime_minutes,
|
||||||
films.runtime_minutes,
|
coalesce(watched_media.watched, 0) as watched
|
||||||
coalesce(watched_media.watched, 0) as watched,
|
from films left join watched_media
|
||||||
coalesce(downloaded_media.downloaded, 0) as downloaded
|
on films.uuid is watched_media.media_uuid
|
||||||
from films
|
|
||||||
left join watched_media on films.uuid is watched_media.media_uuid
|
|
||||||
left join downloaded_media on films.uuid is downloaded_media.media_uuid
|
|
||||||
",
|
",
|
||||||
)?
|
)?
|
||||||
.query(())?
|
.query(())?
|
||||||
|
|
@ -95,32 +92,6 @@ impl SqliteManager {
|
||||||
.await
|
.await
|
||||||
.map_err(convert_error)
|
.map_err(convert_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_film_downloaded_status(
|
|
||||||
&self,
|
|
||||||
uuid: &str,
|
|
||||||
downloaded: bool,
|
|
||||||
) -> Result<(), DataManagerError> {
|
|
||||||
self
|
|
||||||
.client
|
|
||||||
.conn({
|
|
||||||
let uuid = uuid.to_string();
|
|
||||||
move |connection| {
|
|
||||||
connection.execute(
|
|
||||||
"
|
|
||||||
insert into downloaded_media (media_uuid, downloaded)
|
|
||||||
values (:uuid, :downloaded)
|
|
||||||
on conflict (media_uuid) do
|
|
||||||
update set downloaded = :downloaded
|
|
||||||
",
|
|
||||||
named_params! { ":uuid": uuid, ":downloaded": downloaded },
|
|
||||||
)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.map_err(convert_error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for SqliteManager {
|
impl Debug for SqliteManager {
|
||||||
|
|
@ -170,7 +141,6 @@ fn row_to_film_overview(row: &Row) -> rusqlite::Result<FilmOverview> {
|
||||||
let release_date = row.get("release_date")?;
|
let release_date = row.get("release_date")?;
|
||||||
let runtime = row.get("runtime_minutes")?;
|
let runtime = row.get("runtime_minutes")?;
|
||||||
let watched = row.get("watched")?;
|
let watched = row.get("watched")?;
|
||||||
let downloaded = row.get("downloaded")?;
|
|
||||||
|
|
||||||
Ok(FilmOverview {
|
Ok(FilmOverview {
|
||||||
uuid,
|
uuid,
|
||||||
|
|
@ -179,7 +149,6 @@ fn row_to_film_overview(row: &Row) -> rusqlite::Result<FilmOverview> {
|
||||||
release_date,
|
release_date,
|
||||||
runtime,
|
runtime,
|
||||||
watched,
|
watched,
|
||||||
downloaded,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,17 @@ pub struct FilmDetails {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum FilmDetailsInput {
|
pub enum FilmDetailsInput {
|
||||||
ToggleWatchedStatus,
|
ToggleWatchedStatus,
|
||||||
ToggleDownloadedStatus,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum FilmDetailsOutput {
|
pub enum FilmDetailsOutput {
|
||||||
WatchedStatusChanged(bool),
|
WatchedStatusChanged(bool),
|
||||||
DownloadedStatusChanged(bool),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum FilmDetailsCmdOutput {
|
pub enum FilmDetailsCmdOutput {
|
||||||
WatchedStatusPersistSucceeded,
|
WatchedStatusPersistSucceeded,
|
||||||
WatchedStatusPersistFailed(DataManagerError),
|
WatchedStatusPersistFailed(DataManagerError),
|
||||||
DownloadedStatusPersistSucceeded,
|
|
||||||
DownloadedStatusPersistFailed(DataManagerError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component(pub)]
|
#[component(pub)]
|
||||||
|
|
@ -58,23 +54,13 @@ impl Component for FilmDetails {
|
||||||
},
|
},
|
||||||
|
|
||||||
gtk4::Box {
|
gtk4::Box {
|
||||||
set_orientation: Orientation::Horizontal,
|
|
||||||
set_align: Align::Center,
|
set_align: Align::Center,
|
||||||
set_spacing: 20,
|
|
||||||
|
|
||||||
ToggleButton {
|
ToggleButton {
|
||||||
#[watch]
|
#[watch]
|
||||||
set_label: if model.film_overview.watched { "Watched" } else { "Watch" },
|
set_label: if model.film_overview.watched { "Watched" } else { "Watch" },
|
||||||
set_active: model.film_overview.watched,
|
set_active: model.film_overview.watched,
|
||||||
connect_toggled => FilmDetailsInput::ToggleWatchedStatus,
|
connect_toggled => FilmDetailsInput::ToggleWatchedStatus,
|
||||||
},
|
},
|
||||||
|
|
||||||
ToggleButton {
|
|
||||||
#[watch]
|
|
||||||
set_label: if model.film_overview.downloaded { "Downloaded" } else { "Mark downloaded" },
|
|
||||||
set_active: model.film_overview.downloaded,
|
|
||||||
connect_toggled => FilmDetailsInput::ToggleDownloadedStatus,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
gtk4::Box {
|
gtk4::Box {
|
||||||
|
|
@ -125,23 +111,6 @@ impl Component for FilmDetails {
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
FilmDetailsInput::ToggleDownloadedStatus => {
|
|
||||||
let downloaded = !self.film_overview.downloaded;
|
|
||||||
self.film_overview.downloaded = downloaded;
|
|
||||||
sender.emit_output(FilmDetailsOutput::DownloadedStatusChanged(downloaded));
|
|
||||||
|
|
||||||
sender.oneshot_command(clone!(
|
|
||||||
#[strong(rename_to = uuid)]
|
|
||||||
self.film_overview.uuid,
|
|
||||||
async move {
|
|
||||||
let result = DataManager::set_film_downloaded_status(uuid.as_str(), downloaded).await;
|
|
||||||
match result {
|
|
||||||
Ok(()) => FilmDetailsCmdOutput::DownloadedStatusPersistSucceeded,
|
|
||||||
Err(error) => FilmDetailsCmdOutput::DownloadedStatusPersistFailed(error),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,10 +125,6 @@ impl Component for FilmDetails {
|
||||||
FilmDetailsCmdOutput::WatchedStatusPersistFailed(error) => {
|
FilmDetailsCmdOutput::WatchedStatusPersistFailed(error) => {
|
||||||
println!("Watched status persist failed: {error:?}");
|
println!("Watched status persist failed: {error:?}");
|
||||||
}
|
}
|
||||||
FilmDetailsCmdOutput::DownloadedStatusPersistSucceeded => {}
|
|
||||||
FilmDetailsCmdOutput::DownloadedStatusPersistFailed(error) => {
|
|
||||||
println!("Downloaded status persist failed: {error:?}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ pub enum FilmGridItemInput {
|
||||||
ItemClicked,
|
ItemClicked,
|
||||||
DetailsClosed,
|
DetailsClosed,
|
||||||
WatchedStatusChanged(bool),
|
WatchedStatusChanged(bool),
|
||||||
DownloadedStatusChanged(bool),
|
|
||||||
SetVisible(bool),
|
SetVisible(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,9 +74,6 @@ impl FactoryComponent for FilmGridItem {
|
||||||
set_paintable: self.poster.as_ref(),
|
set_paintable: self.poster.as_ref(),
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Wrap widgets below in a box with a set height and center everything vertically
|
|
||||||
// again so that it's not all at the top of the button.
|
|
||||||
|
|
||||||
#[name="name"]
|
#[name="name"]
|
||||||
Label {
|
Label {
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
|
|
@ -96,11 +92,6 @@ impl FactoryComponent for FilmGridItem {
|
||||||
|
|
||||||
#[name="original_name"]
|
#[name="original_name"]
|
||||||
Label {
|
Label {
|
||||||
set_wrap: true,
|
|
||||||
// See above.
|
|
||||||
set_max_width_chars: 1,
|
|
||||||
// Keeps wrapped text centered.
|
|
||||||
set_justify: Justification::Center,
|
|
||||||
set_visible: self.film.original_name.is_some(),
|
set_visible: self.film.original_name.is_some(),
|
||||||
set_cond_label: self.film.original_name.as_deref(),
|
set_cond_label: self.film.original_name.as_deref(),
|
||||||
},
|
},
|
||||||
|
|
@ -128,13 +119,6 @@ impl FactoryComponent for FilmGridItem {
|
||||||
set_visible: self.film.watched,
|
set_visible: self.film.watched,
|
||||||
set_icon_name: Some("eye-outline-filled-symbolic"),
|
set_icon_name: Some("eye-outline-filled-symbolic"),
|
||||||
},
|
},
|
||||||
|
|
||||||
#[name="downloaded"]
|
|
||||||
Image {
|
|
||||||
#[watch]
|
|
||||||
set_visible: self.film.downloaded,
|
|
||||||
set_icon_name: Some("folder-download-symbolic"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -186,7 +170,6 @@ impl FactoryComponent for FilmGridItem {
|
||||||
FilmGridItemInput::ItemClicked => {
|
FilmGridItemInput::ItemClicked => {
|
||||||
let details_controller = FilmDetails::builder()
|
let details_controller = FilmDetails::builder()
|
||||||
.launch(self.film.clone())
|
.launch(self.film.clone())
|
||||||
// TODO: Replace this with Connector::forward.
|
|
||||||
.connect_receiver(clone!(
|
.connect_receiver(clone!(
|
||||||
#[strong]
|
#[strong]
|
||||||
sender,
|
sender,
|
||||||
|
|
@ -194,9 +177,6 @@ impl FactoryComponent for FilmGridItem {
|
||||||
FilmDetailsOutput::WatchedStatusChanged(watched) => {
|
FilmDetailsOutput::WatchedStatusChanged(watched) => {
|
||||||
sender.input(FilmGridItemInput::WatchedStatusChanged(watched));
|
sender.input(FilmGridItemInput::WatchedStatusChanged(watched));
|
||||||
}
|
}
|
||||||
FilmDetailsOutput::DownloadedStatusChanged(downloaded) => {
|
|
||||||
sender.input(FilmGridItemInput::DownloadedStatusChanged(downloaded));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
self.details = Some(details_controller);
|
self.details = Some(details_controller);
|
||||||
|
|
@ -207,9 +187,6 @@ impl FactoryComponent for FilmGridItem {
|
||||||
FilmGridItemInput::WatchedStatusChanged(watched) => {
|
FilmGridItemInput::WatchedStatusChanged(watched) => {
|
||||||
self.film.watched = watched;
|
self.film.watched = watched;
|
||||||
}
|
}
|
||||||
FilmGridItemInput::DownloadedStatusChanged(downloaded) => {
|
|
||||||
self.film.downloaded = downloaded;
|
|
||||||
}
|
|
||||||
FilmGridItemInput::SetVisible(visible) => {
|
FilmGridItemInput::SetVisible(visible) => {
|
||||||
self.visible = visible;
|
self.visible = visible;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,6 @@ impl FactoryComponent for SeriesGridItem {
|
||||||
|
|
||||||
#[name="original_name"]
|
#[name="original_name"]
|
||||||
Label {
|
Label {
|
||||||
set_wrap: true,
|
|
||||||
// See above.
|
|
||||||
set_max_width_chars: 1,
|
|
||||||
// Keeps wrapped text centered.
|
|
||||||
set_visible: self.series.original_name.is_some(),
|
set_visible: self.series.original_name.is_some(),
|
||||||
set_cond_label: self.series.original_name.as_deref(),
|
set_cond_label: self.series.original_name.as_deref(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ pub struct FilmOverview {
|
||||||
// In minutes.
|
// In minutes.
|
||||||
pub runtime: u32,
|
pub runtime: u32,
|
||||||
pub watched: bool,
|
pub watched: bool,
|
||||||
pub downloaded: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue