Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/models/ctx/update_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ pub fn update_library<E: Env + 'static>(
}))
.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::<E>(*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) => {
Expand Down Expand Up @@ -143,17 +162,6 @@ pub fn update_library<E: Env + 'static>(
}))
.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::<E>(*is_watched);
Effects::msg(Msg::Internal(Internal::UpdateLibraryItem(library_item)))
.unchanged()
}
_ => Effects::none().unchanged(),
}
}
Msg::Internal(Internal::UpdateLibraryItem(library_item))
if library
.items
Expand Down
5 changes: 1 addition & 4 deletions src/runtime/msg/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down
1 change: 0 additions & 1 deletion src/runtime/msg/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down