File tree Expand file tree Collapse file tree 3 files changed +19
-18
lines changed
services/static-webserver/client/source/class/osparc Expand file tree Collapse file tree 3 files changed +19
-18
lines changed Original file line number Diff line number Diff line change @@ -699,14 +699,12 @@ qx.Class.define("osparc.data.model.Study", {
699699 /**
700700 * Call patch Study, but the changes were already applied on the frontend
701701 * @param studyDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes.
702- * @param sourceStudy {Object} Study object that was used to apply the diffs on the frontend.
702+ * @param studySource {Object} Study object that was used to check the diffs on the frontend.
703703 */
704- patchStudyDelayed : function ( studyDiffs , sourceStudy ) {
704+ patchStudyDelayed : function ( studyDiffs , studySource ) {
705705 const promises = [ ] ;
706- let workbenchDiffs = { } ;
707706 if ( "workbench" in studyDiffs ) {
708- workbenchDiffs = studyDiffs [ "workbench" ] ;
709- promises . push ( this . getWorkbench ( ) . patchWorkbenchDelayed ( workbenchDiffs ) ) ;
707+ promises . push ( this . getWorkbench ( ) . patchWorkbenchDelayed ( studyDiffs [ "workbench" ] , studySource [ "workbench" ] ) ) ;
710708 delete studyDiffs [ "workbench" ] ;
711709 }
712710 const fieldKeys = Object . keys ( studyDiffs ) ;
@@ -731,7 +729,7 @@ qx.Class.define("osparc.data.model.Study", {
731729 }
732730 return Promise . all ( promises )
733731 . then ( ( ) => {
734- return sourceStudy ;
732+ return studySource ;
735733 } ) ;
736734 }
737735 }
Original file line number Diff line number Diff line change @@ -784,21 +784,26 @@ qx.Class.define("osparc.data.model.Workbench", {
784784 /**
785785 * Call patch Node, but the changes were already applied on the frontend
786786 * @param workbenchDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes.
787+ * @param workbenchSource {Object} Workbench object that was used to check the diffs on the frontend.
787788 */
788- patchWorkbenchDelayed : function ( workbenchDiffs ) {
789+ patchWorkbenchDelayed : function ( workbenchDiffs , workbenchSource ) {
789790 const promises = [ ] ;
790791 Object . keys ( workbenchDiffs ) . forEach ( nodeId => {
791792 const node = this . getNode ( nodeId ) ;
792793 if ( node === null ) {
793794 // the node was removed
794795 return ;
795796 }
797+ // use the node data that was used to check the diffs
798+ const nodeData = workbenchSource [ nodeId ] ;
799+ if ( ! nodeData ) {
800+ // skip if nodeData is undefined or null
801+ return ;
802+ }
796803
797- const nodeData = node . serialize ( ) ;
798804 let patchData = { } ;
799805 if ( workbenchDiffs [ nodeId ] instanceof Array ) {
800- // if workbenchDiffs is an array means that the node was either added or removed
801- // the node was added
806+ // if workbenchDiffs is an array means that the node was added
802807 patchData = nodeData ;
803808 } else {
804809 // patch only what was changed
Original file line number Diff line number Diff line change @@ -858,20 +858,18 @@ qx.Class.define("osparc.desktop.StudyEditor", {
858858
859859 __getStudyDiffs : function ( ) {
860860 const sourceStudy = this . getStudy ( ) . serialize ( ) ;
861+ const studyDiffs = {
862+ sourceStudy,
863+ delta : { } ,
864+ }
861865 const delta = osparc . wrapper . JsonDiffPatch . getInstance ( ) . diff ( this . __studyDataInBackend , sourceStudy ) ;
862866 if ( delta ) {
863867 // lastChangeDate and creationDate should not be taken into account as data change
864868 delete delta [ "creationDate" ] ;
865869 delete delta [ "lastChangeDate" ] ;
866- return {
867- sourceStudy,
868- delta,
869- } ;
870+ studyDiffs . delta = delta ;
870871 }
871- return {
872- sourceStudy,
873- delta : { } ,
874- } ;
872+ return studyDiffs ;
875873 } ,
876874
877875 didStudyChange : function ( ) {
You can’t perform that action at this time.
0 commit comments