Skip to content

Commit 7cbed89

Browse files
committed
remove intervals
1 parent eb700be commit 7cbed89

File tree

1 file changed

+9
-63
lines changed
  • services/static-webserver/client/source/class/osparc/desktop

1 file changed

+9
-63
lines changed

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

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
104104
},
105105

106106
statics: {
107-
AUTO_SAVE_INTERVAL: 3000,
108-
DIFF_CHECK_INTERVAL: 300,
109107
READ_ONLY_TEXT: qx.locale.Manager.tr("You do not have writing permissions.<br>Your changes will not be saved."),
110108
},
111109

@@ -114,8 +112,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
114112
__viewsStack: null,
115113
__workbenchView: null,
116114
__slideshowView: null,
117-
__autoSaveTimer: null,
118-
__savingTimer: null,
119115
__studyEditorIdlingTracker: null,
120116
__studyDataInBackend: null,
121117
__updatingStudy: null,
@@ -221,10 +217,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
221217
}
222218
}
223219

224-
if (osparc.data.model.Study.canIWrite(study.getAccessRights())) {
225-
this.__startAutoSaveTimer();
226-
this.__startSavingTimer();
227-
} else {
220+
if (!osparc.data.model.Study.canIWrite(study.getAccessRights())) {
228221
const msg = this.self().READ_ONLY_TEXT;
229222
osparc.FlashMessenger.logAs(msg, "WARNING");
230223
}
@@ -800,57 +793,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
800793
},
801794
// ------------------ IDLING TRACKER ------------------
802795

803-
// ------------------ AUTO SAVER ------------------
804-
__startAutoSaveTimer: function() {
805-
// Save every 3 seconds
806-
const timer = this.__autoSaveTimer = new qx.event.Timer(this.self().AUTO_SAVE_INTERVAL);
807-
timer.addListener("interval", () => {
808-
if (!osparc.wrapper.WebSocket.getInstance().isConnected()) {
809-
return;
810-
}
811-
this.__checkStudyChanges();
812-
}, this);
813-
timer.start();
814-
},
815-
816-
__stopAutoSaveTimer: function() {
817-
if (this.__autoSaveTimer && this.__autoSaveTimer.isEnabled()) {
818-
this.__autoSaveTimer.stop();
819-
this.__autoSaveTimer.setEnabled(false);
820-
}
821-
},
822-
823-
__restartAutoSaveTimer: function() {
824-
if (this.__autoSaveTimer && this.__autoSaveTimer.isEnabled()) {
825-
this.__autoSaveTimer.restart();
826-
}
827-
},
828-
// ------------------ AUTO SAVER ------------------
829-
830-
// ---------------- SAVING TIMER ------------------
831-
__startSavingTimer: function() {
832-
const timer = this.__savingTimer = new qx.event.Timer(this.self().DIFF_CHECK_INTERVAL);
833-
timer.addListener("interval", () => {
834-
if (!osparc.wrapper.WebSocket.getInstance().isConnected()) {
835-
return;
836-
}
837-
this.getStudy().setSavePending(this.didStudyChange());
838-
}, this);
839-
timer.start();
840-
},
841-
842-
__stopSavingTimer: function() {
843-
if (this.__savingTimer && this.__savingTimer.isEnabled()) {
844-
this.__savingTimer.stop();
845-
this.__savingTimer.setEnabled(false);
846-
}
847-
},
848-
// ---------------- SAVING TIMER ------------------
849-
850796
__stopTimers: function() {
851797
this.__stopIdlingTracker();
852-
this.__stopAutoSaveTimer();
853-
this.__stopSavingTimer();
854798
},
855799

856800
__getStudyDiffs: function() {
@@ -869,12 +813,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
869813
return studyDiffs;
870814
},
871815

872-
// didStudyChange takes around 0.5ms
873-
didStudyChange: function() {
874-
const studyDiffs = this.__getStudyDiffs();
875-
return Boolean(Object.keys(studyDiffs.delta).length);
876-
},
877-
878816
__checkStudyChanges: function() {
879817
if (this.didStudyChange()) {
880818
if (this.__updatingStudy > 0) {
@@ -886,6 +824,14 @@ qx.Class.define("osparc.desktop.StudyEditor", {
886824
}
887825
},
888826

827+
// this takes around 0.5ms
828+
didStudyChange: function() {
829+
const studyDiffs = this.__getStudyDiffs();
830+
const changed = Boolean(Object.keys(studyDiffs.delta).length);
831+
this.getStudy().setSavePending(changed);
832+
return changed;
833+
},
834+
889835
updateStudyDocument: function() {
890836
if (!osparc.data.model.Study.canIWrite(this.getStudy().getAccessRights())) {
891837
return new Promise(resolve => {

0 commit comments

Comments
 (0)