@@ -109,6 +109,45 @@ qx.Class.define("osparc.desktop.StudyEditor", {
109109 DIFF_CHECK_INTERVAL : 300 ,
110110 THROTTLE_PATCH_TIME : 1000 ,
111111 READ_ONLY_TEXT : qx . locale . Manager . tr ( "You do not have writing permissions.<br>Your changes will not be saved." ) ,
112+
113+ curateBackendProjectDocument : function ( projectDocument ) {
114+ // ignore the ``state`` property, it has its own channel
115+ [
116+ "state" ,
117+ ] . forEach ( prop => {
118+ delete projectDocument [ prop ] ;
119+ } ) ;
120+ // in order to pair it the with frontend's node serialization
121+ // remove null entries
122+ // remove state entries
123+ Object . keys ( projectDocument [ "workbench" ] ) . forEach ( nodeId => {
124+ const node = projectDocument [ "workbench" ] [ nodeId ] ;
125+ Object . keys ( node ) . forEach ( nodeProp => {
126+ if ( nodeProp === "state" ) {
127+ delete node [ nodeProp ] ;
128+ }
129+ if ( node [ nodeProp ] === null ) {
130+ delete node [ nodeProp ] ;
131+ }
132+ } ) ;
133+ } ) ;
134+ delete projectDocument [ "ui" ] [ "icon" ] ;
135+ delete projectDocument [ "ui" ] [ "templateType" ] ;
136+ } ,
137+
138+ curateFrontendProjectDocument : function ( myStudy ) {
139+ // the updatedStudy model doesn't contain the following properties
140+ [
141+ "accessRights" ,
142+ "creationDate" ,
143+ "folderId" ,
144+ "prjOwner" ,
145+ "tags" ,
146+ "trashedBy" ,
147+ ] . forEach ( prop => {
148+ delete myStudy [ prop ] ;
149+ } ) ;
150+ }
112151 } ,
113152
114153 members : {
@@ -291,43 +330,13 @@ qx.Class.define("osparc.desktop.StudyEditor", {
291330 if ( ! socket . slotExists ( "projectDocument:updated" ) ) {
292331 socket . on ( "projectDocument:updated" , data => {
293332 if ( data [ "projectId" ] === this . getStudy ( ) . getUuid ( ) ) {
294- const myStudy = this . getStudy ( ) . serialize ( ) ;
295333 const updatedStudy = data [ "document" ] ;
334+ // curate projectDocument:updated document
335+ this . self ( ) . curateBackendProjectDocument ( updatedStudy ) ;
296336
297- // the updatedStudy model doesn't contain the following properties
298- [
299- "accessRights" ,
300- "creationDate" ,
301- "folderId" ,
302- "prjOwner" ,
303- "tags" ,
304- "trashedBy" ,
305- ] . forEach ( prop => {
306- delete myStudy [ prop ] ;
307- } ) ;
308-
309- // ignore the ``state`` property, it has its own channel
310- [
311- "state" ,
312- ] . forEach ( prop => {
313- delete updatedStudy [ prop ] ;
314- } ) ;
315- // in order to pair it the with frontend's node serialization
316- // remove null entries
317- // remove state entries
318- Object . keys ( updatedStudy [ "workbench" ] ) . forEach ( nodeId => {
319- const node = updatedStudy [ "workbench" ] [ nodeId ] ;
320- Object . keys ( node ) . forEach ( nodeProp => {
321- if ( nodeProp === "state" ) {
322- delete node [ nodeProp ] ;
323- }
324- if ( node [ nodeProp ] === null ) {
325- delete node [ nodeProp ] ;
326- }
327- } ) ;
328- } ) ;
329- delete updatedStudy [ "ui" ] [ "icon" ] ;
330- delete updatedStudy [ "ui" ] [ "templateType" ] ;
337+ const myStudy = this . getStudy ( ) . serialize ( ) ;
338+ // curate myStudy
339+ this . self ( ) . curateFrontendProjectDocument ( myStudy ) ;
331340
332341 const delta = osparc . wrapper . JsonDiffPatch . getInstance ( ) . diff ( myStudy , updatedStudy ) ;
333342 console . log ( "projectDocument:updated delta" , myStudy , updatedStudy , delta ) ;
0 commit comments