Add reading list removal
This commit is contained in:
@@ -143,6 +143,7 @@ impl ElyShell {
|
||||
.child(progress_label(entry.progress())),
|
||||
)
|
||||
.child(render_progress_action(index, entry_id, progress, cx))
|
||||
.child(render_remove_action(index, entry.id().clone(), cx))
|
||||
.into_any_element()
|
||||
}
|
||||
}
|
||||
@@ -210,6 +211,23 @@ fn render_progress_action(
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn render_remove_action(
|
||||
index: usize,
|
||||
entry_id: ReadingListId,
|
||||
cx: &mut Context<ElyShell>,
|
||||
) -> AnyElement {
|
||||
Button::new(("remove-reading-list", index))
|
||||
.danger()
|
||||
.xsmall()
|
||||
.icon(IconName::Delete)
|
||||
.label("Remove")
|
||||
.tooltip("Remove From Reading List")
|
||||
.on_click(cx.listener(move |shell, _, _, cx| {
|
||||
shell.remove_reading_list_entry(&entry_id, cx);
|
||||
}))
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn reading_list_count_label(count: usize) -> String {
|
||||
match count {
|
||||
1 => "1 item".to_string(),
|
||||
|
||||
@@ -16,4 +16,16 @@ impl ElyShell {
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn remove_reading_list_entry(
|
||||
&mut self,
|
||||
entry_id: &ReadingListId,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let ShellState::Ready(core) = &mut self.state
|
||||
&& core.remove_reading_list_entry(entry_id).is_ok()
|
||||
{
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user