Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
case "template":
case "tutorial":
case "hypertool":
// when getting the latest study data, the debt information was lost
if (osparc.study.Utils.isInDebt(this.__studyData)) {
const mainStore = qx.store.Store.getInstance();
this.__resourceData["debt"] = mainStore.getStudyDebt(this.__resourceData["uuid"]);
}
osparc.store.Services.getStudyServicesMetadata(latestResourceData)
.finally(() => {
this.__resourceModel = new osparc.data.model.Study(latestResourceData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ qx.Class.define("osparc.store.Store", {
},

members: {
__studiesInDebt: null,

// fetch resources that do not require log in
preloadCalls: async function() {
await osparc.data.Resources.get("config");
Expand Down Expand Up @@ -454,6 +456,16 @@ qx.Class.define("osparc.store.Store", {
},

setStudyDebt: function(studyId, debt) {
// init object if it does not exist
if (this.__studiesInDebt === null) {
this.__studiesInDebt = {};
}
if (debt) {
this.__studiesInDebt[studyId] = debt;
} else {
delete this.__studiesInDebt[studyId];
}

const studiesWStateCache = this.getStudies();
const idx = studiesWStateCache.findIndex(studyWStateCache => studyWStateCache["uuid"] === studyId);
if (idx !== -1) {
Expand All @@ -470,6 +482,17 @@ qx.Class.define("osparc.store.Store", {
});
},

getStudyDebt: function(studyId) {
if (this.__studiesInDebt && studyId in this.__studiesInDebt) {
return this.__studiesInDebt[studyId];
}
return null;
},

isStudyInDebt: function(studyId) {
return Boolean(this.getStudyDebt(studyId));
},

trashStudy: function(studyId) {
const params = {
url: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ qx.Class.define("osparc.study.Utils", {
},

isInDebt: function(studyData) {
return Boolean("debt" in studyData && studyData["debt"] < 0);
return osparc.store.Store.getInstance().isStudyInDebt(studyData["uuid"]);
},

getUiMode: function(studyData) {
Expand Down
Loading