Skip to content

Commit 3e3296f

Browse files
committed
refactor
1 parent a58201f commit 3e3296f

File tree

1 file changed

+17
-20
lines changed
  • services/static-webserver/client/source/class/osparc/study

1 file changed

+17
-20
lines changed

services/static-webserver/client/source/class/osparc/study/Utils.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -375,37 +375,34 @@ qx.Class.define("osparc.study.Utils", {
375375
},
376376

377377
state: {
378+
__getShareState: function(state) {
379+
if (state && "shareState" in state) {
380+
return state["shareState"];
381+
}
382+
return null;
383+
},
384+
378385
getProjectStatus: function(state) {
379-
if (
380-
state &&
381-
"shareState" in state &&
382-
"status" in state["shareState"]
383-
) {
384-
return state["shareState"]["status"];
386+
const shareState = this.__getShareState(state);
387+
if (shareState && "status" in shareState) {
388+
return shareState["status"];
385389
}
386390
return null;
387391
},
388392

389393
isProjectLocked: function(state) {
390-
if (
391-
state &&
392-
"shareState" in state &&
393-
"locked" in state["shareState"]
394-
) {
395-
return state["shareState"]["locked"];
394+
const shareState = this.__getShareState(state);
395+
if (shareState && "locked" in shareState) {
396+
return shareState["locked"];
396397
}
397398
return false;
398399
},
399400

400401
getCurrentGroupIds: function(state) {
401-
if (
402-
state &&
403-
"shareState" in state &&
404-
"currentUserGroupids" in state["shareState"]
405-
) {
406-
return state["shareState"]["currentUserGroupids"];
402+
const shareState = this.__getShareState(state);
403+
if (shareState && "currentUserGroupids" in shareState) {
404+
return shareState["currentUserGroupids"];
407405
}
408-
409406
return [];
410407
},
411408

@@ -449,7 +446,7 @@ qx.Class.define("osparc.study.Utils", {
449446
return "UNKNOWN_SERVICES";
450447
}
451448
}
452-
if (studyData["state"] && studyData["state"]["shareState"] && studyData["state"]["shareState"]["locked"]) {
449+
if (this.isProjectLocked(studyData)) {
453450
return "IN_USE";
454451
}
455452
if (this.isInDebt(studyData)) {

0 commit comments

Comments
 (0)