changeset 719:633bb89d4a6e rtviewer19branch

Fixes to auxiliary parameters management
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 20 May 2019 19:55:13 +0200
parents df7286320507
children 556822c70742
files Platforms/Wasm/wasm-application-runner.ts
diffstat 1 files changed, 19 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Platforms/Wasm/wasm-application-runner.ts	Mon May 20 19:06:45 2019 +0200
+++ b/Platforms/Wasm/wasm-application-runner.ts	Mon May 20 19:55:13 2019 +0200
@@ -73,23 +73,29 @@
 
   CreateWasmApplication();
 
-  // transmit the API-specified parameters to the app before initializing it
-  for (let key in auxiliaryParameters) {
-    if (auxiliaryParameters.hasOwnProperty(key)) {
-      Logger.defaultLogger.debug(
-        `About to call SetStartupParameter("${key}","${auxiliaryParameters[key]}")`);
-      SetStartupParameter(key, auxiliaryParameters[key]);
+  // parse uri and transmit the URI parameters to the app before initializing it
+  let parameters = GetUriParameters();
+
+  // merge params but give priority to URI parameters
+  var resultingParams : Map<string,string>;
+  
+  if (auxiliaryParameters == null) {
+    resultingParams = new Map<string,string>();
+  } else {
+    resultingParams = auxiliaryParameters;
+  }
+
+  for (let key in parameters) {
+    if (parameters.hasOwnProperty(key)) {
+      resultingParams[key] = parameters[key]
     }
   }
 
-  // parse uri and transmit the URI parameters to the app before initializing it
-  let parameters = GetUriParameters();
-
-  for (let key in parameters) {
-    if (parameters.hasOwnProperty(key)) {
+  for (let key in resultingParams) {
+    if (resultingParams.hasOwnProperty(key)) {
       Logger.defaultLogger.debug(
-        `About to call SetStartupParameter("${key}","${parameters[key]}")`);
-      SetStartupParameter(key, parameters[key]);
+        `About to call SetStartupParameter("${key}","${resultingParams[key]}")`);
+      SetStartupParameter(key, resultingParams[key]);
     }
   }