@@ -160,6 +160,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
160160 __savingTimer : null ,
161161 __studyEditorIdlingTracker : null ,
162162 __lastSyncedProjectDocument : null ,
163+ __lastSyncedProjectVersion : null ,
163164 __updatingStudy : null ,
164165 __updateThrottled : null ,
165166 __nodesSlidesTree : null ,
@@ -332,12 +333,22 @@ qx.Class.define("osparc.desktop.StudyEditor", {
332333 if ( ! socket . slotExists ( "projectDocument:updated" ) ) {
333334 socket . on ( "projectDocument:updated" , data => {
334335 if ( data [ "projectId" ] === this . getStudy ( ) . getUuid ( ) ) {
336+
337+ // OM replace this by sessionId
335338 if ( data [ "userPrimaryGid" ] === osparc . auth . Data . getInstance ( ) . getGroupId ( ) ) {
336339 // ignore my own updates
337340 console . debug ( "Ignoring my own projectDocument:updated event" , data ) ;
338341 return ;
339342 }
340343
344+ const documentVersion = data [ "version" ] ;
345+ if ( this . __lastSyncedProjectVersion && documentVersion <= this . __lastSyncedProjectVersion ) {
346+ // ignore old updates
347+ console . debug ( "Ignoring old projectDocument:updated event" , data ) ;
348+ return ;
349+ }
350+ this . __lastSyncedProjectVersion = documentVersion ;
351+
341352 const updatedStudy = data [ "document" ] ;
342353 // curate projectDocument:updated document
343354 this . self ( ) . curateBackendProjectDocument ( updatedStudy ) ;
@@ -346,8 +357,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
346357 // curate myStudy
347358 this . self ( ) . curateFrontendProjectDocument ( myStudy ) ;
348359
349- // this.__setLastSyncedProjectDocument(updatedStudy);
350-
351360 this . __blockUpdates = true ;
352361 const delta = osparc . wrapper . JsonDiffPatch . getInstance ( ) . diff ( myStudy , updatedStudy ) ;
353362 const jsonPatches = osparc . wrapper . JsonDiffPatch . getInstance ( ) . deltaToJsonPatches ( delta ) ;
0 commit comments