Add note removal
This commit is contained in:
@@ -2,7 +2,7 @@ use std::time::{Duration, SystemTime};
|
||||
|
||||
use ely_browser_core::BrowserSnapshot;
|
||||
use ely_design_system::colors;
|
||||
use ely_domain::NoteEntry;
|
||||
use ely_domain::{NoteEntry, NoteId};
|
||||
use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
AnyElement, Context, InteractiveElement, IntoElement, ParentElement, SharedString,
|
||||
@@ -79,6 +79,7 @@ impl ElyShell {
|
||||
) -> AnyElement {
|
||||
let url = note.source_url().clone();
|
||||
let open_url = note.source_url().clone();
|
||||
let note_id = note.id().clone();
|
||||
let space_name = note_space_name(snapshot, note);
|
||||
|
||||
div()
|
||||
@@ -161,6 +162,7 @@ impl ElyShell {
|
||||
shell.open_url(open_url.clone(), window, cx);
|
||||
})),
|
||||
)
|
||||
.child(render_remove_note_action(index, note_id, cx))
|
||||
.into_any_element()
|
||||
}
|
||||
}
|
||||
@@ -207,6 +209,23 @@ fn notes_count_label(count: usize) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn render_remove_note_action(
|
||||
index: usize,
|
||||
note_id: NoteId,
|
||||
cx: &mut Context<ElyShell>,
|
||||
) -> AnyElement {
|
||||
Button::new(("remove-note", index))
|
||||
.danger()
|
||||
.xsmall()
|
||||
.icon(IconName::Delete)
|
||||
.label("Remove")
|
||||
.tooltip("Remove Note")
|
||||
.on_click(cx.listener(move |shell, _, _, cx| {
|
||||
shell.remove_note_entry(¬e_id, cx);
|
||||
}))
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn markdown_preview(body: &str) -> String {
|
||||
let preview = body
|
||||
.lines()
|
||||
|
||||
@@ -2,6 +2,7 @@ mod bookmarks;
|
||||
mod downloads;
|
||||
mod history;
|
||||
mod internal_pages;
|
||||
mod notes;
|
||||
mod plugins;
|
||||
mod reading_list;
|
||||
mod render;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
use ely_domain::NoteId;
|
||||
use gpui::Context;
|
||||
|
||||
use super::{ElyShell, ShellState};
|
||||
|
||||
impl ElyShell {
|
||||
pub(super) fn remove_note_entry(&mut self, note_id: &NoteId, cx: &mut Context<Self>) {
|
||||
if let ShellState::Ready(core) = &mut self.state
|
||||
&& core.remove_note_entry(note_id).is_ok()
|
||||
{
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user