Skip to content

Commit 5a53b19

Browse files
committed
check context
1 parent c0b2fb3 commit 5a53b19

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
223223
this._loadingResourcesBtn.setVisibility("visible");
224224
this.__getNextStudiesRequest()
225225
.then(resp => {
226-
if (
227-
"workspaceId" in resp["params"]["url"] &&
228-
(
229-
resp["params"]["url"].workspaceId !== this.getCurrentWorkspaceId() ||
230-
resp["params"]["url"].folderId !== this.getCurrentFolderId()
231-
)
232-
) {
233-
// Context might have been changed while waiting for the response.
234-
// The new call is on the ways and this can be ignored.
235-
return;
226+
const urlParams = resp["params"]["url"];
227+
// Context might have been changed while waiting for the response.
228+
// The new call is on the way, therefore this response can be ignored.
229+
if ("workspaceId" in urlParams) {
230+
if (
231+
urlParams.workspaceId !== this.getCurrentWorkspaceId() ||
232+
urlParams.folderId !== this.getCurrentFolderId()
233+
) {
234+
return;
235+
}
236+
} else if ("text" in urlParams) {
237+
const currentFilterData = this._searchBarFilter.getFilterData();
238+
if (currentFilterData.text && urlParams.text !== encodeURIComponent(currentFilterData.text)) {
239+
return;
240+
}
236241
}
237242

238243
const studies = resp["data"];
@@ -645,17 +650,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
645650
const filterData = this._searchBarFilter.getFilterData();
646651
if (filterData.text) {
647652
params.url.text = encodeURIComponent(filterData.text); // name, description and uuid
648-
} else {
649-
params.url.workspaceId = this.getCurrentWorkspaceId();
650-
params.url.folderId = this.getCurrentFolderId();
651-
}
652-
653-
if (params.url.text) {
654-
delete params.url.orderBy;
655653
return osparc.data.Resources.fetch("studies", "getPageSearch", params, undefined, options);
656-
} else if (params.url.orderBy) {
657-
return osparc.data.Resources.fetch("studies", "getPageSortBy", params, undefined, options);
658654
}
655+
656+
params.url.workspaceId = this.getCurrentWorkspaceId();
657+
params.url.folderId = this.getCurrentFolderId();
659658
return osparc.data.Resources.fetch("studies", "getPage", params, undefined, options);
660659
},
661660

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,14 @@ qx.Class.define("osparc.data.Resources", {
119119
url: statics.API + "/projects?type=user"
120120
},
121121
getPage: {
122-
method: "GET",
123-
url: statics.API + "/projects?type=user&offset={offset}&limit={limit}&workspace_id={workspaceId}&folder_id={folderId}"
124-
},
125-
getPageSortBy: {
126122
useCache: false,
127123
method: "GET",
128124
url: statics.API + "/projects?type=user&offset={offset}&limit={limit}&workspace_id={workspaceId}&folder_id={folderId}&order_by={orderBy}"
129125
},
130126
getPageSearch: {
131127
useCache: false,
132128
method: "GET",
133-
url: statics.API + "/projects:search?offset={offset}&limit={limit}&text={text}"
129+
url: statics.API + "/projects:search?offset={offset}&limit={limit}&text={text}&order_by={orderBy}"
134130
// url: statics.API + "/projects:search?offset={offset}&limit={limit}&text={text}&tags={tags}&order_by={orderBy}"
135131
},
136132
getOne: {

0 commit comments

Comments
 (0)