Add note removal

This commit is contained in:
2026-05-08 06:59:03 -04:00
parent 7e68857eb8
commit 818e8e550d
6 changed files with 80 additions and 4 deletions
+5 -2
View File
@@ -1,6 +1,6 @@
use ely_domain::{
BookmarkId, DomainError, DownloadId, PluginId, ProfileId, ReadingListId, SpaceId, SplitId,
TabId,
BookmarkId, DomainError, DownloadId, NoteId, PluginId, ProfileId, ReadingListId, SpaceId,
SplitId, TabId,
};
use thiserror::Error;
@@ -30,6 +30,9 @@ pub enum CoreError {
#[error("reading list entry not found: {id}")]
ReadingListEntryNotFound { id: ReadingListId },
#[error("note not found: {id}")]
NoteNotFound { id: NoteId },
#[error("download target path is unavailable: {id}")]
DownloadTargetPathUnavailable { id: DownloadId },
@@ -87,6 +87,19 @@ impl BrowserCore {
.collect()
}
pub fn remove_note_entry(&mut self, note_id: &NoteId) -> Result<(), CoreError> {
let index = self.note_entry_index(note_id)?;
self.notes.remove(index);
Ok(())
}
fn note_entry_index(&self, note_id: &NoteId) -> Result<usize, CoreError> {
self.notes
.iter()
.position(|entry| entry.id() == note_id)
.ok_or_else(|| CoreError::NoteNotFound { id: note_id.clone() })
}
fn note_index_for_target(
&self,
profile_id: &ely_domain::ProfileId,