Skip to content

Commit 5de2391

Browse files
committed
avoid changing the selection when the PreResources are not yet loaded
1 parent 504e04e commit 5de2391

File tree

1 file changed

+28
-8
lines changed
  • services/static-webserver/client/source/class/osparc/dashboard

1 file changed

+28
-8
lines changed

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

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ qx.Class.define("osparc.dashboard.Dashboard", {
6969
appearance: {
7070
init: "dashboard",
7171
refine: true
72-
}
72+
},
73+
74+
preResourcePromisesLoaded: {
75+
check: "Boolean",
76+
init: false,
77+
event: "changePreResourcePromisesLoaded"
78+
},
7379
},
7480

7581
statics: {
@@ -187,6 +193,7 @@ qx.Class.define("osparc.dashboard.Dashboard", {
187193
preResourcePromises.push(osparc.store.Services.getServicesLatest(false));
188194
Promise.all(preResourcePromises)
189195
.then(() => {
196+
this.setPreResourcePromisesLoaded(true);
190197
if (this.__studyBrowser) {
191198
this.__studyBrowser.initResources();
192199
}
@@ -196,15 +203,28 @@ qx.Class.define("osparc.dashboard.Dashboard", {
196203
if (this.__dataBrowser) {
197204
this.__dataBrowser.initResources();
198205
}
199-
200-
this.addListener("changeSelection", e => {
201-
const selectedTab = e.getData()[0];
202-
if (selectedTab && selectedTab.resourceBrowser) {
203-
selectedTab.resourceBrowser.initResources();
204-
}
205-
}, this);
206206
})
207207
.catch(err => console.error(err));
208+
209+
this.addListener("changeSelection", e => {
210+
const selectedTab = e.getData()[0];
211+
if (selectedTab && selectedTab.resourceBrowser) {
212+
// avoid changing the selection when the PreResources are not yet loaded
213+
if (this.getPreResourcePromisesLoaded()) {
214+
selectedTab.resourceBrowser.initResources();
215+
} else {
216+
const initTab = event => {
217+
if (event.getData()) {
218+
selectedTab.resourceBrowser.initResources();
219+
}
220+
};
221+
this.addListener("changePreResourcePromisesLoaded", ev => {
222+
initTab(ev);
223+
this.removeListener("changePreResourcePromisesLoaded", initTab);
224+
});
225+
}
226+
}
227+
}, this);
208228
},
209229

210230
__createStudyBrowser: function() {

0 commit comments

Comments
 (0)