Add bookmarks internal page

This commit is contained in:
2026-05-08 00:44:43 -04:00
parent b4aedad593
commit e225fac222
14 changed files with 487 additions and 16 deletions
+100
View File
@@ -0,0 +1,100 @@
use std::time::SystemTime;
use crate::{BookmarkId, DomainError, ProfileId, SpaceId, UrlText};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BookmarkEntry {
id: BookmarkId,
profile_id: ProfileId,
space_id: SpaceId,
collection_name: String,
title: String,
url: UrlText,
tags: Vec<String>,
note: Option<String>,
added_at: SystemTime,
}
impl BookmarkEntry {
pub fn new(
profile_id: ProfileId,
space_id: SpaceId,
collection_name: impl Into<String>,
title: impl Into<String>,
url: UrlText,
added_at: SystemTime,
) -> Result<Self, DomainError> {
let collection_name = non_empty_text("bookmark collection", collection_name.into())?;
let title = non_empty_text("bookmark title", title.into())?;
Ok(Self {
id: BookmarkId::new(),
profile_id,
space_id,
collection_name,
title,
url,
tags: Vec::new(),
note: None,
added_at,
})
}
#[must_use]
pub fn id(&self) -> &BookmarkId {
&self.id
}
#[must_use]
pub fn profile_id(&self) -> &ProfileId {
&self.profile_id
}
#[must_use]
pub fn space_id(&self) -> &SpaceId {
&self.space_id
}
#[must_use]
pub fn collection_name(&self) -> &str {
&self.collection_name
}
#[must_use]
pub fn title(&self) -> &str {
&self.title
}
#[must_use]
pub fn url(&self) -> &UrlText {
&self.url
}
#[must_use]
pub fn display_url(&self) -> String {
self.url.display_url()
}
#[must_use]
pub fn tags(&self) -> &[String] {
&self.tags
}
#[must_use]
pub fn note(&self) -> Option<&str> {
self.note.as_deref()
}
#[must_use]
pub fn added_at(&self) -> SystemTime {
self.added_at
}
}
fn non_empty_text(field: &'static str, value: String) -> Result<String, DomainError> {
let trimmed = value.trim();
if trimmed.is_empty() {
return Err(DomainError::EmptyField { field });
}
Ok(trimmed.to_string())
}
+1
View File
@@ -39,3 +39,4 @@ entity_id!(ProfileId, "profile");
entity_id!(SplitId, "split");
entity_id!(WebViewId, "webview");
entity_id!(DownloadId, "download");
entity_id!(BookmarkId, "bookmark");
+3 -1
View File
@@ -1,4 +1,5 @@
mod archive;
mod bookmark;
mod command;
mod download;
mod error;
@@ -13,6 +14,7 @@ mod tab;
mod url_text;
pub use archive::{ArchiveSource, ArchivedTab};
pub use bookmark::BookmarkEntry;
pub use command::{CommandIntent, CommandScope};
pub use download::{
DownloadChecksum, DownloadChecksumAlgorithm, DownloadDestination, DownloadEntry,
@@ -20,7 +22,7 @@ pub use download::{
};
pub use error::DomainError;
pub use history::HistoryEntry;
pub use identifiers::{DownloadId, ProfileId, SpaceId, SplitId, TabId, WebViewId};
pub use identifiers::{BookmarkId, DownloadId, ProfileId, SpaceId, SplitId, TabId, WebViewId};
pub use plugin::{
PluginContributionPoint, PluginId, PluginManifest, PluginPermission, PluginPermissionRisk,
PluginSignature, PluginSignatureAlgorithm,
+1
View File
@@ -7,6 +7,7 @@ pub enum SyncConnectionState {
pub enum SyncObjectKind {
Spaces,
Tabs,
Bookmarks,
Profiles,
History,
PluginSettings,