From dbb5a6640158c42b4fc93f0535da83c077c67cc5 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 22 Nov 2024 14:24:11 +0100 Subject: [PATCH 1/4] compare strings and integers --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 0c8e3701ec8..87c9e03b7cb 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -631,7 +631,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // check the entries in currentParams are the same as the reqParams let sameContext = true; Object.entries(currentParams).forEach(([key, value]) => { - sameContext &= key in reqParams && reqParams[key] === value; + sameContext &= key in reqParams && reqParams[key] == value; }); return !sameContext; }, From 1c43a7994bb62f6dbc48620cc59d105ddbec771a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 22 Nov 2024 14:25:05 +0100 Subject: [PATCH 2/4] renaming --- .../source/class/osparc/dashboard/StudyBrowser.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 87c9e03b7cb..5f729894db7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -637,10 +637,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __getNextPageParams: function() { - if (this._resourcesContainer.getFlatList() && this._resourcesContainer.getFlatList().nextRequest) { + const studiesContainer = this._resourcesContainer.getFlatList(); + if (studiesContainer && studiesContainer.nextRequest) { // Context might have been changed while waiting for the response. // The new call is on the way, therefore this response can be ignored. - const url = new URL(this._resourcesContainer.getFlatList().nextRequest); + const url = new URL(studiesContainer.nextRequest); const urlSearchParams = new URLSearchParams(url.search); const urlParams = {}; for (const [snakeKey, value] of urlSearchParams.entries()) { @@ -650,12 +651,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const contextChanged = this.__didContextChange(urlParams); if ( !contextChanged && - osparc.utils.Utils.hasParamFromURL(this._resourcesContainer.getFlatList().nextRequest, "offset") && - osparc.utils.Utils.hasParamFromURL(this._resourcesContainer.getFlatList().nextRequest, "limit") + osparc.utils.Utils.hasParamFromURL(studiesContainer.nextRequest, "offset") && + osparc.utils.Utils.hasParamFromURL(studiesContainer.nextRequest, "limit") ) { return { - offset: osparc.utils.Utils.getParamFromURL(this._resourcesContainer.getFlatList().nextRequest, "offset"), - limit: osparc.utils.Utils.getParamFromURL(this._resourcesContainer.getFlatList().nextRequest, "limit") + offset: osparc.utils.Utils.getParamFromURL(studiesContainer.nextRequest, "offset"), + limit: osparc.utils.Utils.getParamFromURL(studiesContainer.nextRequest, "limit") }; } } From 3ed6e06b062978cc5c6679a5e68ee9e6e86efd91 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 22 Nov 2024 14:41:21 +0100 Subject: [PATCH 3/4] comment --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 1 + 1 file changed, 1 insertion(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 5f729894db7..882848dd295 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -631,6 +631,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // check the entries in currentParams are the same as the reqParams let sameContext = true; Object.entries(currentParams).forEach(([key, value]) => { + // loose equality: will do a Number to String conversion if necessary sameContext &= key in reqParams && reqParams[key] == value; }); return !sameContext; From 2d9d09a10d91f81a20d02ed57a8bd0800926a317 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 22 Nov 2024 15:02:41 +0100 Subject: [PATCH 4/4] less patching --- .../client/source/class/osparc/data/model/Workbench.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/model/Workbench.js b/services/static-webserver/client/source/class/osparc/data/model/Workbench.js index 822f5d59eff..d442cb03b63 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Workbench.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Workbench.js @@ -797,7 +797,10 @@ qx.Class.define("osparc.data.model.Workbench", { } else { // patch only what was changed Object.keys(workbenchDiffs[nodeId]).forEach(changedFieldKey => { - patchData[changedFieldKey] = nodeData[changedFieldKey]; + if (nodeData[changedFieldKey] !== undefined) { + // do not patch if it's undefined + patchData[changedFieldKey] = nodeData[changedFieldKey]; + } }); } const params = { @@ -807,7 +810,9 @@ qx.Class.define("osparc.data.model.Workbench", { }, data: patchData }; - promises.push(osparc.data.Resources.fetch("studies", "patchNode", params)); + if (Object.keys(patchData).length) { + promises.push(osparc.data.Resources.fetch("studies", "patchNode", params)); + } }) return Promise.all(promises); }