Track tab sync participation
This commit is contained in:
@@ -76,7 +76,7 @@ impl BrowserCore {
|
||||
),
|
||||
self.sync_object_status(
|
||||
SyncObjectKind::Tabs,
|
||||
self.tabs.len(),
|
||||
self.sync_enabled_tab_count(),
|
||||
SyncObjectState::LocalOnly,
|
||||
),
|
||||
self.sync_object_status(
|
||||
@@ -126,4 +126,8 @@ impl BrowserCore {
|
||||
|
||||
SyncObjectStatus::with_policy(kind, local_count, state, policy)
|
||||
}
|
||||
|
||||
fn sync_enabled_tab_count(&self) -> usize {
|
||||
self.tabs.iter().filter(|tab| tab.sync_enabled()).count()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +243,20 @@ impl BrowserCore {
|
||||
Ok(next_pinned)
|
||||
}
|
||||
|
||||
pub fn set_tab_sync_enabled(
|
||||
&mut self,
|
||||
tab_id: &TabId,
|
||||
sync_enabled: bool,
|
||||
) -> Result<(), CoreError> {
|
||||
let tab = self
|
||||
.tabs
|
||||
.iter_mut()
|
||||
.find(|tab| tab.id() == tab_id)
|
||||
.ok_or_else(|| CoreError::TabNotFound { id: tab_id.clone() })?;
|
||||
tab.set_sync_enabled(sync_enabled);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn active_tab(&self) -> Result<&BrowserTab, CoreError> {
|
||||
self.tabs
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user