diff --git a/src/models/ctx/update_library.rs b/src/models/ctx/update_library.rs index a4d384cbe..936fad799 100644 --- a/src/models/ctx/update_library.rs +++ b/src/models/ctx/update_library.rs @@ -101,6 +101,25 @@ pub fn update_library( })) .unchanged(), }, + Msg::Action(Action::Ctx(ActionCtx::MarkAsWatched(id, watched))) => { + match library.items.get(id) { + Some(library_item) => { + let mut library_item = library_item.to_owned(); + library_item.mark_as_watched::(*watched); + + Effects::msg(Msg::Internal(Internal::UpdateLibraryItem(library_item))) + .join(Effects::msg(Msg::Event( + Event::LibraryItemMarkedAsWatched { id: id.to_owned() }, + ))) + .unchanged() + } + _ => Effects::msg(Msg::Event(Event::Error { + error: CtxError::from(OtherError::LibraryItemNotFound), + source: Box::new(Event::LibraryItemMarkedAsWatched { id: id.to_owned() }), + })) + .unchanged(), + } + } Msg::Action(Action::Ctx(ActionCtx::ToggleLibraryItemNotifications(id, state))) => { match library.items.get(id) { Some(library_item) => { @@ -143,17 +162,6 @@ pub fn update_library( })) .unchanged(), }, - Msg::Action(Action::Ctx(ActionCtx::LibraryItemMarkAsWatched { id, is_watched })) => { - match library.items.get(id) { - Some(library_item) => { - let mut library_item = library_item.to_owned(); - library_item.mark_as_watched::(*is_watched); - Effects::msg(Msg::Internal(Internal::UpdateLibraryItem(library_item))) - .unchanged() - } - _ => Effects::none().unchanged(), - } - } Msg::Internal(Internal::UpdateLibraryItem(library_item)) if library .items diff --git a/src/runtime/msg/action.rs b/src/runtime/msg/action.rs index 1ed66fb1a..181972d08 100644 --- a/src/runtime/msg/action.rs +++ b/src/runtime/msg/action.rs @@ -45,10 +45,7 @@ pub enum ActionCtx { AddToLibrary(MetaItemPreview), RemoveFromLibrary(String), RewindLibraryItem(String), - LibraryItemMarkAsWatched { - id: LibraryItemId, - is_watched: bool, - }, + MarkAsWatched(String, bool), /// If boolean is set to `true` it will disable notifications for the LibraryItem. ToggleLibraryItemNotifications(LibraryItemId, bool), /// Dismiss all Notification for a given [`MetaItemId`]. diff --git a/src/runtime/msg/event.rs b/src/runtime/msg/event.rs index 0f068fe6d..674d74043 100644 --- a/src/runtime/msg/event.rs +++ b/src/runtime/msg/event.rs @@ -130,7 +130,6 @@ pub enum Event { /// The LibraryItem with the given id has been marked as watched or unwatched (Overrides the previous watched state) LibraryItemMarkedAsWatched { id: LibraryItemId, - is_watched: bool, }, /// The notifications for the given LibraryItemId have been dismissed NotificationsDismissed {