refactor(sync): split snapshot apply coordinator
This commit is contained in:
@@ -30,6 +30,7 @@ mod space_exports;
|
||||
mod spaces;
|
||||
mod splits;
|
||||
mod sync;
|
||||
mod sync_apply;
|
||||
mod sync_context;
|
||||
mod sync_notes;
|
||||
mod sync_profiles;
|
||||
|
||||
@@ -9,7 +9,7 @@ use ely_sync_client::SyncClientError;
|
||||
|
||||
use super::{BrowserCore, sync_context::SyncSnapshotApplyContext};
|
||||
use crate::sync_engine::SyncSnapshotApplySummary;
|
||||
use crate::sync_records::{BookmarkSyncRecord, SpaceSyncRecord, SyncSnapshotBody, TabSyncRecord};
|
||||
use crate::sync_records::{BookmarkSyncRecord, SpaceSyncRecord, TabSyncRecord};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct SyncObjectPolicies {
|
||||
@@ -106,33 +106,6 @@ impl BrowserCore {
|
||||
.map(|space| space.name().to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn apply_sync_snapshot_body(
|
||||
&mut self,
|
||||
body: SyncSnapshotBody,
|
||||
) -> Result<SyncSnapshotApplySummary, SyncClientError> {
|
||||
let mut summary = SyncSnapshotApplySummary::default();
|
||||
let mut context = SyncSnapshotApplyContext::default();
|
||||
for record in body.profiles {
|
||||
self.apply_profile_sync_record(record, &mut summary, &mut context)?;
|
||||
}
|
||||
for record in body.spaces {
|
||||
self.apply_space_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.tabs {
|
||||
self.apply_tab_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.bookmarks {
|
||||
self.apply_bookmark_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.notes {
|
||||
self.apply_note_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.reading_list {
|
||||
self.apply_reading_list_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
Ok(summary)
|
||||
}
|
||||
|
||||
pub(super) fn sync_status(&self) -> SyncStatus {
|
||||
let enabled_state = match &self.sync_connection_state {
|
||||
SyncConnectionState::SyncReady { .. } => SyncObjectState::Synced,
|
||||
@@ -218,7 +191,7 @@ impl BrowserCore {
|
||||
self.spaces.iter().collect()
|
||||
}
|
||||
|
||||
fn apply_space_sync_record(
|
||||
pub(super) fn apply_space_sync_record(
|
||||
&mut self,
|
||||
record: SpaceSyncRecord,
|
||||
summary: &mut SyncSnapshotApplySummary,
|
||||
@@ -297,7 +270,7 @@ impl BrowserCore {
|
||||
changed
|
||||
}
|
||||
|
||||
fn apply_tab_sync_record(
|
||||
pub(super) fn apply_tab_sync_record(
|
||||
&mut self,
|
||||
record: TabSyncRecord,
|
||||
summary: &mut SyncSnapshotApplySummary,
|
||||
@@ -346,7 +319,7 @@ impl BrowserCore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn apply_bookmark_sync_record(
|
||||
pub(super) fn apply_bookmark_sync_record(
|
||||
&mut self,
|
||||
record: BookmarkSyncRecord,
|
||||
summary: &mut SyncSnapshotApplySummary,
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
use ely_sync_client::SyncClientError;
|
||||
|
||||
use super::{BrowserCore, sync_context::SyncSnapshotApplyContext};
|
||||
use crate::{sync_engine::SyncSnapshotApplySummary, sync_records::SyncSnapshotBody};
|
||||
|
||||
impl BrowserCore {
|
||||
pub(crate) fn apply_sync_snapshot_body(
|
||||
&mut self,
|
||||
body: SyncSnapshotBody,
|
||||
) -> Result<SyncSnapshotApplySummary, SyncClientError> {
|
||||
let mut summary = SyncSnapshotApplySummary::default();
|
||||
let mut context = SyncSnapshotApplyContext::default();
|
||||
for record in body.profiles {
|
||||
self.apply_profile_sync_record(record, &mut summary, &mut context)?;
|
||||
}
|
||||
for record in body.spaces {
|
||||
self.apply_space_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.tabs {
|
||||
self.apply_tab_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.bookmarks {
|
||||
self.apply_bookmark_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.notes {
|
||||
self.apply_note_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
for record in body.reading_list {
|
||||
self.apply_reading_list_sync_record(record, &mut summary, &context)?;
|
||||
}
|
||||
Ok(summary)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user