Skip to content

Commit 8b8f694

Browse files
committed
track debt in store
1 parent 4dcff91 commit 8b8f694

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
5151
return;
5252
}
5353
this.__resourceData = osparc.utils.Utils.deepCloneObject(latestResourceData);
54-
// quick solution
55-
if ("debt" in resourceData) {
56-
this.__resourceData["debt"] = resourceData["debt"];
57-
}
5854
this.__resourceData["resourceType"] = resourceData["resourceType"];
5955
switch (resourceData["resourceType"]) {
6056
case "study":
6157
case "template":
6258
case "tutorial":
6359
case "hypertool":
60+
const mainStore = qx.store.Store.getInstance();
61+
if (mainStore.getStudyDebt(this.__resourceData["uuid"])) {
62+
this.__resourceData["debt"] = mainStore.getStudyDebt(this.__resourceData["uuid"]);
63+
}
6464
osparc.store.Services.getStudyServicesMetadata(latestResourceData)
6565
.finally(() => {
6666
this.__resourceModel = new osparc.data.model.Study(latestResourceData);

services/static-webserver/client/source/class/osparc/store/Store.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ qx.Class.define("osparc.store.Store", {
253253
},
254254

255255
members: {
256+
__studiesInDebt: null,
257+
256258
// fetch resources that do not require log in
257259
preloadCalls: async function() {
258260
await osparc.data.Resources.get("config");
@@ -454,6 +456,15 @@ qx.Class.define("osparc.store.Store", {
454456
},
455457

456458
setStudyDebt: function(studyId, debt) {
459+
if (this.__studiesInDebt === null) {
460+
this.__studiesInDebt = {};
461+
}
462+
if (debt) {
463+
this.__studiesInDebt[studyId] = debt;
464+
} else {
465+
delete this.__studiesInDebt[studyId];
466+
}
467+
457468
const studiesWStateCache = this.getStudies();
458469
const idx = studiesWStateCache.findIndex(studyWStateCache => studyWStateCache["uuid"] === studyId);
459470
if (idx !== -1) {
@@ -470,6 +481,13 @@ qx.Class.define("osparc.store.Store", {
470481
});
471482
},
472483

484+
getStudyDebt: function(studyId) {
485+
if (this.__studiesInDebt && studyId in this.__studiesInDebt) {
486+
return this.__studiesInDebt[studyId];
487+
}
488+
return null;
489+
},
490+
473491
trashStudy: function(studyId) {
474492
const params = {
475493
url: {

0 commit comments

Comments
 (0)