@@ -80,6 +80,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
8080 flex : 1
8181 } ) ;
8282
83+ this . __lastSyncedProjectDocument = null ;
84+ this . __lastSyncedVersion = null ;
8385 this . __updatingStudy = 0 ;
8486 this . __throttledPatchPending = false ;
8587 } ,
@@ -158,7 +160,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
158160 __autoSaveTimer : null ,
159161 __savingTimer : null ,
160162 __studyEditorIdlingTracker : null ,
161- __studyDataInBackend : null ,
163+ __lastSyncedProjectDocument : null ,
164+ __lastSyncedVersion : null ,
162165 __updatingStudy : null ,
163166 __updateThrottled : null ,
164167 __nodesSlidesTree : null ,
@@ -192,7 +195,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
192195
193196 study . openStudy ( )
194197 . then ( studyData => {
195- this . __setStudyDataInBackend ( studyData ) ;
198+ this . __setLastSyncedProjectDocument ( studyData ) ;
196199
197200 this . __workbenchView . setStudy ( study ) ;
198201 this . __slideshowView . setStudy ( study ) ;
@@ -301,13 +304,16 @@ qx.Class.define("osparc.desktop.StudyEditor", {
301304 }
302305 } ,
303306
304- __setStudyDataInBackend : function ( studyData ) {
305- this . __studyDataInBackend = osparc . data . model . Study . deepCloneStudyObject ( studyData , true ) ;
307+ __setLastSyncedProjectDocument : function ( studyData , version ) {
308+ this . __lastSyncedProjectDocument = osparc . data . model . Study . deepCloneStudyObject ( studyData , true ) ;
309+ if ( version !== undefined ) {
310+ this . __lastSyncedVersion = version ;
311+ }
306312
307- // remove the runHash, this.__studyDataInBackend is only used for diff comparison and the frontend doesn't keep it
308- Object . keys ( this . __studyDataInBackend [ "workbench" ] ) . forEach ( nodeId => {
309- if ( "runHash" in this . __studyDataInBackend [ "workbench" ] [ nodeId ] ) {
310- delete this . __studyDataInBackend [ "workbench" ] [ nodeId ] [ "runHash" ] ;
313+ // remove the runHash, this.__lastSyncedProjectDocument is only used for diff comparison and the frontend doesn't keep it
314+ Object . keys ( this . __lastSyncedProjectDocument [ "workbench" ] ) . forEach ( nodeId => {
315+ if ( "runHash" in this . __lastSyncedProjectDocument [ "workbench" ] [ nodeId ] ) {
316+ delete this . __lastSyncedProjectDocument [ "workbench" ] [ nodeId ] [ "runHash" ] ;
311317 }
312318 } ) ;
313319 } ,
@@ -344,6 +350,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
344350 this . getStudy ( ) . getUi ( ) . updateUiFromDiff ( delta [ "ui" ] ) ;
345351 delete delta [ "ui" ] ;
346352 }
353+
354+ this . __lastSyncedVersion = data [ "version" ] ;
347355 }
348356 } , this ) ;
349357 }
@@ -945,7 +953,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
945953 sourceStudy,
946954 delta : { } ,
947955 }
948- const delta = osparc . wrapper . JsonDiffPatch . getInstance ( ) . diff ( this . __studyDataInBackend , sourceStudy ) ;
956+ const delta = osparc . wrapper . JsonDiffPatch . getInstance ( ) . diff ( this . __lastSyncedProjectDocument , sourceStudy ) ;
949957 if ( delta ) {
950958 // lastChangeDate and creationDate should not be taken into account as data change
951959 delete delta [ "creationDate" ] ;
@@ -1006,7 +1014,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
10061014 this . __updatingStudy ++ ;
10071015 const studyDiffs = this . __getStudyDiffs ( ) ;
10081016 return this . getStudy ( ) . patchStudyDelayed ( studyDiffs . delta , studyDiffs . sourceStudy )
1009- . then ( studyData => this . __setStudyDataInBackend ( studyData ) )
1017+ . then ( studyData => this . __setLastSyncedProjectDocument ( studyData ) )
10101018 . catch ( error => {
10111019 if ( "status" in error && error . status === 409 ) {
10121020 console . log ( "Flash message blocked" ) ; // Workaround for osparc-issues #1189
0 commit comments