Add reading list progress actions

This commit is contained in:
2026-05-08 06:23:21 -04:00
parent fc00840697
commit e13557814d
7 changed files with 152 additions and 16 deletions
@@ -1,6 +1,6 @@
use std::time::SystemTime;
use ely_domain::{ReadingListEntry, ReadingListId, UrlText};
use ely_domain::{ReadingListEntry, ReadingListId, ReadingProgress, UrlText};
use crate::CoreError;
@@ -27,6 +27,15 @@ impl BrowserCore {
Ok(entry_id)
}
pub fn set_reading_list_progress(
&mut self,
entry_id: &ReadingListId,
progress: ReadingProgress,
) -> Result<(), CoreError> {
self.reading_list_entry_mut(entry_id)?.set_progress(progress);
Ok(())
}
pub(super) fn find_reading_list_match(&self, query: &str) -> Option<UrlText> {
let normalized_query = query.trim().to_lowercase();
if normalized_query.is_empty() {
@@ -48,6 +57,16 @@ impl BrowserCore {
.cloned()
.collect()
}
fn reading_list_entry_mut(
&mut self,
entry_id: &ReadingListId,
) -> Result<&mut ReadingListEntry, CoreError> {
self.reading_list
.iter_mut()
.find(|entry| entry.id() == entry_id)
.ok_or_else(|| CoreError::ReadingListEntryNotFound { id: entry_id.clone() })
}
}
fn reading_list_entry_matches_query(entry: &ReadingListEntry, normalized_query: &str) -> bool {