Add reading list progress percent

This commit is contained in:
2026-05-08 06:43:38 -04:00
parent 8dd610fec3
commit bae3c7789f
8 changed files with 169 additions and 15 deletions
+25 -1
View File
@@ -1,4 +1,6 @@
use ely_domain::{BrowserTab, PluginId, SearchEngine, SiteOrigin, UrlText};
use ely_domain::{
BrowserTab, DomainError, PluginId, ReadingProgressPercent, SearchEngine, SiteOrigin, UrlText,
};
use url::Url;
use crate::CoreError;
@@ -67,6 +69,28 @@ pub(crate) fn archive_idle_days(command: &str) -> Option<u16> {
.and_then(|value| value.parse().ok())
}
pub(crate) fn reading_progress_percent(
command: &str,
) -> Result<Option<ReadingProgressPercent>, CoreError> {
let Some(value) = command_argument(
command,
&[
"reading-progress ",
"reading progress ",
"set-reading-progress ",
"set reading progress ",
],
) else {
return Ok(None);
};
let percent_text = value.trim().strip_suffix('%').unwrap_or(value.trim()).trim();
let percent = percent_text.parse::<u8>().map_err(|_| {
DomainError::InvalidReadingProgressPercent { value: value.trim().to_string() }
})?;
ReadingProgressPercent::new(percent).map(Some).map_err(CoreError::from)
}
pub(crate) fn new_profile_name(command: &str) -> Option<&str> {
command_argument(command, &["new-profile ", "new profile "])
}
@@ -7,9 +7,9 @@ use crate::{
navigation::{
about_url, archive_idle_days, archive_url, bookmarks_url, downloads_url, history_url,
move_tab_space_name, new_private_profile_name, new_profile_name, new_space_name,
plugin_detail_url, plugins_url, reading_list_url, search_url, settings_page_url,
settings_url, shortcut_settings_url, space_icon, switch_profile_name, sync_status_url,
task_manager_url,
plugin_detail_url, plugins_url, reading_list_url, reading_progress_percent, search_url,
settings_page_url, settings_url, shortcut_settings_url, space_icon, switch_profile_name,
sync_status_url, task_manager_url,
},
};
@@ -123,6 +123,10 @@ impl BrowserCore {
self.archive_idle_tabs(SystemTime::now())?;
return Ok(true);
}
if let Some(percent) = reading_progress_percent(command)? {
self.set_active_tab_reading_progress(percent)?;
return Ok(true);
}
match command.to_ascii_lowercase().as_str() {
"new-tab" => {
@@ -1,6 +1,8 @@
use std::time::SystemTime;
use ely_domain::{ReadingListEntry, ReadingListId, ReadingProgress, UrlText};
use ely_domain::{
ReadingListEntry, ReadingListId, ReadingProgress, ReadingProgressPercent, UrlText,
};
use crate::CoreError;
@@ -36,6 +38,15 @@ impl BrowserCore {
Ok(())
}
pub fn set_active_tab_reading_progress(
&mut self,
percent: ReadingProgressPercent,
) -> Result<ReadingListId, CoreError> {
let entry_id = self.save_active_tab_to_reading_list()?;
self.set_reading_list_progress(&entry_id, ReadingProgress::InProgress(percent))?;
Ok(entry_id)
}
pub fn remove_reading_list_entry(&mut self, entry_id: &ReadingListId) -> Result<(), CoreError> {
let index = self.reading_list_entry_index(entry_id)?;
self.reading_list.remove(index);