Add recent history clear confirmation

This commit is contained in:
2026-05-08 04:31:19 -04:00
parent 71750114a6
commit 349597d283
5 changed files with 257 additions and 8 deletions
@@ -21,6 +21,15 @@ impl BrowserCore {
self.clear_space_profile_history_for_host(&profile_id, &space_id, host)
}
pub fn clear_active_space_history_since(
&mut self,
cutoff: SystemTime,
) -> Result<usize, crate::CoreError> {
let profile_id = self.active_profile_id.clone();
let space_id = self.active_space_id.clone();
self.clear_space_profile_history_since(&profile_id, &space_id, cutoff)
}
pub(super) fn record_history_entry(&mut self, tab: &BrowserTab) {
if !self.history_recording_policy.records_history()
|| !records_history(tab.url())
@@ -108,6 +117,28 @@ impl BrowserCore {
Ok(original_count - self.history_entries.len())
}
fn clear_space_profile_history_since(
&mut self,
profile_id: &ProfileId,
space_id: &SpaceId,
cutoff: SystemTime,
) -> Result<usize, crate::CoreError> {
if !self.profiles.iter().any(|profile| profile.id() == profile_id) {
return Err(crate::CoreError::ProfileNotFound { id: profile_id.clone() });
}
if !self.spaces.iter().any(|space| space.id() == space_id) {
return Err(crate::CoreError::SpaceNotFound { id: space_id.clone() });
}
let original_count = self.history_entries.len();
self.history_entries.retain(|entry| {
entry.profile_id() != profile_id
|| entry.space_id() != space_id
|| entry.visited_at() < cutoff
});
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,