Mountain/Environment/DocumentProvider/
ApplyChanges.rs1use CommonLibrary::Error::CommonError::CommonError;
7use log::{trace, warn};
8use serde_json::Value;
9use url::Url;
10
11use crate::Environment::Utility;
12
13pub(super) async fn apply_document_changes(
15 environment:&crate::Environment::MountainEnvironment::MountainEnvironment,
16 uri:Url,
17 new_version_identifier:i64,
18 changes_dto_collection:Value,
19 _is_dirty_after_change:bool,
20 _is_undoing:bool,
21 _is_redoing:bool,
22) -> Result<(), CommonError> {
23 trace!("[DocumentProvider] Applying changes to document: {}", uri);
24
25 {
26 let mut open_documents_guard = environment
27 .ApplicationState
28 .Feature
29 .Documents
30 .OpenDocuments
31 .lock()
32 .map_err(Utility::MapApplicationStateLockErrorToCommonError)?;
33
34 if let Some(document) = open_documents_guard.get_mut(uri.as_str()) {
35 document.ApplyChanges(new_version_identifier, &changes_dto_collection)?;
36 } else {
37 warn!("[DocumentProvider] Received changes for unknown document: {}", uri);
38
39 return Ok(());
40 }
41 }
42
43 super::Notifications::notify_model_changed(environment, &uri, new_version_identifier, changes_dto_collection).await;
44
45 Ok(())
46}