Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Correctly interpret string arguments as booleans in electron arguments. #1536

Merged
merged 4 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

<br/>![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)
Expand All @@ -28,6 +32,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
[1531]: https://github.com/enso-org/ide/pull/1531

<br/>
Expand Down
39 changes: 33 additions & 6 deletions src/js/lib/content/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";



Expand Down Expand Up @@ -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 parseBooleanOrLeaveAsIs(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 parseAllBooleans(config) {
for (const key in config) {
config[key] = parseBooleanOrLeaveAsIs(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 = {
Expand All @@ -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)
parseAllBooleans(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.
Expand Down