Skip to content

Commit 3841505

Browse files
committed
Remove DocState::LocallyCreatedButNotEdited
1 parent a393021 commit 3841505

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

src/repo.rs

+12-27
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl RepoHandle {
137137
pub fn new_document(&self) -> DocHandle {
138138
let document_id = DocumentId::random();
139139
let document = new_document();
140-
let doc_info = self.new_document_info(document, DocState::LocallyCreatedNotEdited);
140+
let doc_info = self.new_document_info(document, DocState::Sync(vec![]));
141141
let handle = DocHandle::new(
142142
self.repo_sender.clone(),
143143
document_id.clone(),
@@ -316,11 +316,6 @@ pub(crate) enum DocState {
316316
resolver: RepoFutureResolver<Result<Option<DocHandle>, RepoError>>,
317317
storage_fut: BoxFuture<'static, Result<Option<Vec<u8>>, StorageError>>,
318318
},
319-
/// A document that has been locally created,
320-
/// and not edited yet,
321-
/// should not be synced
322-
/// until it has been locally edited.
323-
LocallyCreatedNotEdited,
324319
/// The doc is syncing(can be edited locally),
325320
/// and polling pending storage save operations.
326321
Sync(Vec<BoxFuture<'static, Result<(), StorageError>>>),
@@ -341,7 +336,6 @@ impl fmt::Debug for DocState {
341336
f.write_str(&input)
342337
}
343338
DocState::LoadPending { .. } => f.write_str("DocState::LoadPending"),
344-
DocState::LocallyCreatedNotEdited => f.write_str("DocState::LocallyCreatedNotEdited"),
345339
DocState::Sync(_) => f.write_str("DocState::Sync"),
346340
DocState::PendingRemoval(_) => f.write_str("DocState::PendingRemoval"),
347341
DocState::Error => f.write_str("DocState::Error"),
@@ -655,10 +649,7 @@ impl DocumentInfo {
655649

656650
fn start_pending_removal(&mut self) {
657651
self.state = match &mut self.state {
658-
DocState::LocallyCreatedNotEdited
659-
| DocState::Error
660-
| DocState::LoadPending { .. }
661-
| DocState::Bootstrap { .. } => {
652+
DocState::Error | DocState::LoadPending { .. } | DocState::Bootstrap { .. } => {
662653
assert_eq!(self.changes_since_last_compact, 0);
663654
DocState::PendingRemoval(vec![])
664655
}
@@ -1387,10 +1378,6 @@ impl Repo {
13871378
if info.note_changes() {
13881379
self.documents_with_changes.push(doc_id.clone());
13891380
}
1390-
let is_first_edit = matches!(info.state, DocState::LocallyCreatedNotEdited);
1391-
if is_first_edit {
1392-
info.state = DocState::Sync(vec![]);
1393-
}
13941381
for (to_repo_id, message) in info.generate_sync_messages().into_iter() {
13951382
let outgoing = NetworkMessage::Sync {
13961383
from_repo_id: local_repo_id.clone(),
@@ -1404,18 +1391,16 @@ impl Repo {
14041391
.push_back(outgoing);
14051392
self.sinks_to_poll.insert(to_repo_id);
14061393
}
1407-
if is_first_edit {
1408-
// Send a sync message to all other repos we are connected with and with
1409-
// whom we should share this document
1410-
Self::enqueue_share_decisions(
1411-
self.remote_repos.keys(),
1412-
&mut self.pending_share_decisions,
1413-
&mut self.share_decisions_to_poll,
1414-
self.share_policy.as_ref(),
1415-
doc_id.clone(),
1416-
ShareType::Announce,
1417-
);
1418-
}
1394+
// Send a sync message to all other repos we are connected with and with
1395+
// whom we should share this document
1396+
Self::enqueue_share_decisions(
1397+
self.remote_repos.keys(),
1398+
&mut self.pending_share_decisions,
1399+
&mut self.share_decisions_to_poll,
1400+
self.share_policy.as_ref(),
1401+
doc_id.clone(),
1402+
ShareType::Announce,
1403+
);
14191404
}
14201405
}
14211406
RepoEvent::DocClosed(doc_id) => {

0 commit comments

Comments
 (0)