From 0ef25e3f20e43db54933f5046b1e32ac4699be71 Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Thu, 29 Apr 2021 11:58:44 +0200 Subject: [PATCH 1/3] fix: Correctly interpret string arguments as booleans. --- src/js/lib/content/src/index.js | 39 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/js/lib/content/src/index.js b/src/js/lib/content/src/index.js index 48b8b6a8ea..f55a1f82d6 100644 --- a/src/js/lib/content/src/index.js +++ b/src/js/lib/content/src/index.js @@ -7,6 +7,7 @@ import * as html_utils from 'enso-studio-common/src/html_utils' import * as animation from 'enso-studio-common/src/animation' import * as globalConfig from '../../../../config.yaml' import cfg from '../../../config' +import assert from "assert"; @@ -438,6 +439,36 @@ function ok(value) { return value !== null && value !== undefined } +/// Check whether the value is a string with value `"true"`/`"false"`, if so, return the +// appropriate boolean instead. Otherwise, return the original value. +function tryAsBoolean(value) { + if (value === "true"){ + return true + } + if (value === "false"){ + return false + } + return value +} + +/// Turn all values that have a boolean in string representation (`"true"`/`"false"`) into actual +/// booleans (`true/`false``). +function ensureBooleans(config) { + for (const key in config) { + config[key] = tryAsBoolean(config[key]) + } +} + +function initLogging(config) { + assert(typeof config.no_data_gathering == "boolean") + if (config.no_data_gathering ) { + API.remoteLog = function (_event, _data) {} + } else { + let logger = new MixpanelLogger + API.remoteLog = function (event,data) {logger.log(event,data)} + } +} + /// Main entry point. Loads WASM, initializes it, chooses the scene to run. API.main = async function (inputConfig) { let defaultConfig = { @@ -451,14 +482,10 @@ API.main = async function (inputConfig) { let urlParams = new URLSearchParams(window.location.search); let urlConfig = Object.fromEntries(urlParams.entries()) let config = Object.assign(defaultConfig,inputConfig,urlConfig) + ensureBooleans(config) API[globalConfig.windowAppScopeConfigName] = config - if (config.no_data_gathering) { - API.remoteLog = function (_event, _data) {} - } else { - let logger = new MixpanelLogger - API.remoteLog = function (event,data) {logger.log(event,data)} - } + initLogging(config) window.setInterval(() =>{API.remoteLog("alive");}, ALIVE_LOG_INTERVAL) //Build data injected during the build process. See `webpack.config.js` for the source. From 73f901fe91ae04284d9ed9d6e66de5670685f1c9 Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Thu, 29 Apr 2021 15:26:21 +0200 Subject: [PATCH 2/3] chore: Update changelog. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 259f6e4242..2202efcd75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@
![Bug Fixes](/docs/assets/tags/bug_fixes.svg) +- [Fix some internal settings not being applied correctly in the IDE][1536]. + Some arguments were not passed correctly to the IDE leading to erroneous + behaviour in the electron app. This is now fixed. + #### Visual Environment #### EnsoGL (rendering engine) @@ -23,6 +27,7 @@ you can find their release notes [here](https://github.com/enso-org/enso/blob/main/RELEASES.md). [1511]: https://github.com/enso-org/ide/pull/1511 +[1511]: https://github.com/enso-org/ide/pull/1536
From 93f294626b61d76fe7e3e972c9abf3cdeee057f0 Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Thu, 29 Apr 2021 16:58:42 +0200 Subject: [PATCH 3/3] refactor: Apply name change suggestions. --- src/js/lib/content/src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/lib/content/src/index.js b/src/js/lib/content/src/index.js index f55a1f82d6..bd239b9d05 100644 --- a/src/js/lib/content/src/index.js +++ b/src/js/lib/content/src/index.js @@ -441,7 +441,7 @@ function ok(value) { /// Check whether the value is a string with value `"true"`/`"false"`, if so, return the // appropriate boolean instead. Otherwise, return the original value. -function tryAsBoolean(value) { +function parseBooleanOrLeaveAsIs(value) { if (value === "true"){ return true } @@ -453,9 +453,9 @@ function tryAsBoolean(value) { /// Turn all values that have a boolean in string representation (`"true"`/`"false"`) into actual /// booleans (`true/`false``). -function ensureBooleans(config) { +function parseAllBooleans(config) { for (const key in config) { - config[key] = tryAsBoolean(config[key]) + config[key] = parseBooleanOrLeaveAsIs(config[key]) } } @@ -482,7 +482,7 @@ API.main = async function (inputConfig) { let urlParams = new URLSearchParams(window.location.search); let urlConfig = Object.fromEntries(urlParams.entries()) let config = Object.assign(defaultConfig,inputConfig,urlConfig) - ensureBooleans(config) + parseAllBooleans(config) API[globalConfig.windowAppScopeConfigName] = config initLogging(config)