Simplify watched status toggling in film details modal

This commit is contained in:
Reinout Meliesie 2026-01-26 12:16:54 +01:00
commit ebf777a73b
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6

View file

@ -15,7 +15,7 @@ pub struct FilmDetails {
#[derive(Debug)] #[derive(Debug)]
pub enum FilmDetailsInput { pub enum FilmDetailsInput {
WatchedStatusChanged(bool), ToggleWatchedStatus,
} }
#[derive(Debug)] #[derive(Debug)]
@ -59,9 +59,7 @@ impl Component for FilmDetails {
#[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[sender] => move |watch_button| { connect_toggled => FilmDetailsInput::ToggleWatchedStatus,
sender.input(FilmDetailsInput::WatchedStatusChanged(watch_button.is_active()));
},
}, },
}, },
@ -96,7 +94,8 @@ impl Component for FilmDetails {
_root: &gtk4::Box, _root: &gtk4::Box,
) { ) {
match message { match message {
FilmDetailsInput::WatchedStatusChanged(watched) => { FilmDetailsInput::ToggleWatchedStatus => {
let watched = !self.film_overview.watched;
self.film_overview.watched = watched; self.film_overview.watched = watched;
sender.emit_output(FilmDetailsOutput::WatchedStatusChanged(watched)); sender.emit_output(FilmDetailsOutput::WatchedStatusChanged(watched));