@@ -164,6 +164,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
164164 __updateThrottled : null ,
165165 __nodesSlidesTree : null ,
166166 __throttledPatchPending : null ,
167+ __blockUpdates : null ,
167168
168169 setStudyData : function ( studyData ) {
169170 if ( this . __settingStudy ) {
@@ -339,14 +340,16 @@ qx.Class.define("osparc.desktop.StudyEditor", {
339340 // curate myStudy
340341 this . self ( ) . curateFrontendProjectDocument ( myStudy ) ;
341342
342- this . __setLastSyncedProjectDocument ( updatedStudy ) ;
343+ // this.__setLastSyncedProjectDocument(updatedStudy);
343344
345+ this . __blockUpdates = true ;
344346 const delta = osparc . wrapper . JsonDiffPatch . getInstance ( ) . diff ( myStudy , updatedStudy ) ;
345347 console . log ( "projectDocument:updated delta" , myStudy , updatedStudy , delta ) ;
346348 if ( "ui" in delta ) {
347349 this . getStudy ( ) . getUi ( ) . updateUiFromDiff ( delta [ "ui" ] ) ;
348350 delete delta [ "ui" ] ;
349351 }
352+ this . __blockUpdates = false ;
350353 }
351354 } , this ) ;
352355 }
@@ -977,28 +980,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
977980 }
978981 } ,
979982
980- __isEchoLoop : function ( patchData ) {
981- return false ;
982- // check if the patchData is an echo loop, i.e. it is the same as the last synced project document
983- // if it is, return true
984- const pathParts = patchData [ "path" ] . split ( "/" ) . slice ( 1 ) ; // remove the first empty part
985- let currentValue = this . __lastSyncedProjectDocument ;
986- for ( const part of pathParts ) {
987- if ( currentValue && part in currentValue ) {
988- currentValue = currentValue [ part ] ;
989- } else {
990- // if the path doesn't exist in the last synced project document, return false
991- return false ;
992- }
993- }
994- // values can be any type, so we need to check if they are equal
995- if ( JSON . stringify ( currentValue ) === JSON . stringify ( patchData [ "value" ] ) ) {
996- // if both values are null, return true
997- return true ;
998- }
999- return false ;
1000- } ,
1001-
1002983 /**
1003984 * @param {JSON Patch } data It will soon be used to patch the project document https://datatracker.ietf.org/doc/html/rfc6902
1004985 */
@@ -1008,8 +989,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
1008989 console . log ( "projectDocumentChanged" , patchData ) ;
1009990 }
1010991 // avoid echo loop
1011- if ( this . __isEchoLoop ( patchData ) ) {
1012- console . warn ( "Echo loop detected, ignoring patchData" , patchData ) ;
992+ if ( this . __blockUpdates ) {
1013993 return ;
1014994 }
1015995
0 commit comments