Simplify watched status toggling in film details modal
This commit is contained in:
parent
e1fbc92e08
commit
ebf777a73b
1 changed files with 4 additions and 5 deletions
|
|
@ -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: >k4::Box,
|
_root: >k4::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));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue