Add expired space trash purge
This commit is contained in:
@@ -381,6 +381,13 @@ impl BrowserCore {
|
||||
self.archive_idle_tabs(SystemTime::now())?;
|
||||
Ok(true)
|
||||
}
|
||||
"purge-expired-spaces"
|
||||
| "purge expired spaces"
|
||||
| "purge-space-trash"
|
||||
| "purge space trash" => {
|
||||
self.purge_expired_trashed_spaces(SystemTime::now());
|
||||
Ok(true)
|
||||
}
|
||||
"favorite" | "toggle-favorite" => {
|
||||
self.toggle_active_tab_favorite()?;
|
||||
Ok(true)
|
||||
|
||||
@@ -51,6 +51,11 @@ impl TrashedSpace {
|
||||
pub fn purge_at(&self) -> SystemTime {
|
||||
self.purge_at
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn is_expired(&self, now: SystemTime) -> bool {
|
||||
now >= self.purge_at
|
||||
}
|
||||
}
|
||||
|
||||
impl BrowserCore {
|
||||
@@ -190,6 +195,12 @@ impl BrowserCore {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
pub fn purge_expired_trashed_spaces(&mut self, now: SystemTime) -> usize {
|
||||
let previous_count = self.trashed_spaces.len();
|
||||
self.trashed_spaces.retain(|space| !space.is_expired(now));
|
||||
previous_count - self.trashed_spaces.len()
|
||||
}
|
||||
|
||||
pub fn move_space_up(&mut self, space_id: &SpaceId) -> Result<bool, CoreError> {
|
||||
let mut ordered_ids = self.sorted_space_ids();
|
||||
let Some(index) = ordered_ids.iter().position(|id| id == space_id) else {
|
||||
|
||||
Reference in New Issue
Block a user