Add profile history clear confirmation
This commit is contained in:
@@ -55,6 +55,7 @@ pub struct BrowserSnapshot {
|
||||
pub site_permission_audit_events: Vec<SitePermissionAuditEvent>,
|
||||
pub download_entries: Vec<DownloadEntry>,
|
||||
pub history_entries: Vec<HistoryEntry>,
|
||||
pub active_profile_history_entry_count: usize,
|
||||
pub split_layouts: Vec<SplitLayout>,
|
||||
pub installed_plugins: Vec<InstalledPlugin>,
|
||||
pub plugin_audit_events: Vec<PluginAuditEvent>,
|
||||
@@ -291,6 +292,7 @@ impl BrowserCore {
|
||||
site_permission_audit_events: self.visible_site_permission_audit_events(),
|
||||
download_entries: self.visible_downloads(),
|
||||
history_entries: self.visible_history(),
|
||||
active_profile_history_entry_count: self.active_profile_history_count(),
|
||||
split_layouts: self.visible_split_layouts(),
|
||||
installed_plugins: self.installed_plugins.clone(),
|
||||
plugin_audit_events: self.plugin_audit_events.clone(),
|
||||
|
||||
@@ -7,6 +7,11 @@ use crate::navigation::records_history;
|
||||
use super::BrowserCore;
|
||||
|
||||
impl BrowserCore {
|
||||
pub fn clear_active_profile_history(&mut self) -> Result<usize, crate::CoreError> {
|
||||
let profile_id = self.active_profile_id.clone();
|
||||
self.clear_profile_history(&profile_id)
|
||||
}
|
||||
|
||||
pub(super) fn record_history_entry(&mut self, tab: &BrowserTab) {
|
||||
if !self.history_recording_policy.records_history()
|
||||
|| !records_history(tab.url())
|
||||
@@ -50,6 +55,23 @@ impl BrowserCore {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(super) fn active_profile_history_count(&self) -> usize {
|
||||
self.history_entries
|
||||
.iter()
|
||||
.filter(|entry| entry.profile_id() == &self.active_profile_id)
|
||||
.count()
|
||||
}
|
||||
|
||||
fn clear_profile_history(&mut self, profile_id: &ProfileId) -> Result<usize, crate::CoreError> {
|
||||
if !self.profiles.iter().any(|profile| profile.id() == profile_id) {
|
||||
return Err(crate::CoreError::ProfileNotFound { id: profile_id.clone() });
|
||||
}
|
||||
|
||||
let original_count = self.history_entries.len();
|
||||
self.history_entries.retain(|entry| entry.profile_id() != profile_id);
|
||||
Ok(original_count - self.history_entries.len())
|
||||
}
|
||||
|
||||
fn profile_records_history(&self, profile_id: &ProfileId) -> bool {
|
||||
match self.profiles.iter().find(|profile| profile.id() == profile_id) {
|
||||
Some(profile) => profile.kind() == &ProfileKind::Standard,
|
||||
|
||||
Reference in New Issue
Block a user