Add tab group refresh command
This commit is contained in:
@@ -216,6 +216,9 @@ impl BrowserCore {
|
||||
"sleep-tab-group" | "sleep tab group" | "discard-tab-group" | "discard tab group" => {
|
||||
Ok(self.discard_active_tab_group()?.is_some())
|
||||
}
|
||||
"refresh-tab-group" | "refresh tab group" | "reload-tab-group" | "reload tab group" => {
|
||||
Ok(self.refresh_active_tab_group()?.is_some())
|
||||
}
|
||||
"close-tab-group" | "close tab group" | "archive-tab-group" | "archive tab group" => {
|
||||
Ok(self.close_active_tab_group()?.is_some())
|
||||
}
|
||||
|
||||
@@ -93,6 +93,19 @@ impl BrowserCore {
|
||||
Ok(Some(tab_ids.len()))
|
||||
}
|
||||
|
||||
pub fn refresh_active_tab_group(&mut self) -> Result<Option<usize>, CoreError> {
|
||||
let Some(group_id) = self.active_tab_group_id()? else {
|
||||
return Ok(None);
|
||||
};
|
||||
let tab_ids = self.active_space_group_tab_ids(&group_id);
|
||||
|
||||
for tab_id in &tab_ids {
|
||||
self.refresh_tab(tab_id)?;
|
||||
}
|
||||
|
||||
Ok(Some(tab_ids.len()))
|
||||
}
|
||||
|
||||
pub fn close_active_tab_group(&mut self) -> Result<Option<usize>, CoreError> {
|
||||
let Some(group_id) = self.active_tab_group_id()? else {
|
||||
return Ok(None);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::time::SystemTime;
|
||||
|
||||
use ely_domain::TabId;
|
||||
|
||||
use super::BrowserCore;
|
||||
@@ -42,6 +44,20 @@ impl BrowserCore {
|
||||
self.mark_tab_ready(tab_id)
|
||||
}
|
||||
|
||||
pub(super) fn refresh_tab(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
{
|
||||
let tab = self
|
||||
.tabs
|
||||
.iter_mut()
|
||||
.find(|tab| tab.id() == tab_id)
|
||||
.ok_or_else(|| CoreError::TabNotFound { id: tab_id.clone() })?;
|
||||
tab.mark_ready();
|
||||
}
|
||||
|
||||
self.record_tab_activity(tab_id, SystemTime::now());
|
||||
Ok(tab_id.clone())
|
||||
}
|
||||
|
||||
fn mark_tab_ready(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
{
|
||||
let tab = self
|
||||
|
||||
Reference in New Issue
Block a user