Skip to content

Commit da94e9c

Browse files
committed
after a reconnect, re-sync the project document
1 parent 0b964c2 commit da94e9c

File tree

1 file changed

+20
-0
lines changed
  • services/static-webserver/client/source/class/osparc/desktop

1 file changed

+20
-0
lines changed

services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,26 @@ qx.Class.define("osparc.desktop.StudyEditor", {
316316
this.__listenToEvent();
317317
this.__listenToServiceStatus();
318318
this.__listenToStatePorts();
319+
320+
const socket = osparc.wrapper.WebSocket.getInstance();
321+
[
322+
"connect",
323+
"reconnect",
324+
].forEach(evtName => {
325+
socket.addListener(evtName, () => {
326+
// after a reconnect, re-sync the project document
327+
console.log("WebSocket reconnected, re-syncing project document");
328+
const studyId = this.getStudy().getUuid();
329+
osparc.store.Study.getInstance().getOne(studyId)
330+
.then(latestStudyData => {
331+
const latestData = {
332+
"version": this.__lastSyncedProjectVersion, // do not increase the version
333+
"document": latestStudyData,
334+
};
335+
this.__applyProjectDocument(latestData);
336+
});
337+
});
338+
});
319339
},
320340

321341
__listenToProjectDocument: function() {

0 commit comments

Comments
 (0)