diff --git a/docs-src/docs/advanced-functionality/view-settings.md b/docs-src/docs/advanced-functionality/view-settings.md index 5325225b0..a7b86b997 100644 --- a/docs-src/docs/advanced-functionality/view-settings.md +++ b/docs-src/docs/advanced-functionality/view-settings.md @@ -37,6 +37,7 @@ For instance, if you set `display_defaults.color_by` to `country`, but load the | `layout` | Tree layout | "rect", "radial", "clock" or "unrooted | | `branch_label` | Which set of branch labels are to be displayed | "aa", "lineage" | | `panels` | List of panels which (if available) are to be displayed | ["tree", "map"] | +| `transmission_lines`| Should transmission lines (if available) be rendered on the map? | Boolean | Note that `meta.display_defaults.panels` (optional) differs from `meta.panels` (required), where the latter lists the possible panels that auspice may display for the dataset. diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index b69db6c97..274c88152 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -192,11 +192,11 @@ const modifyStateViaMetadata = (state, metadata) => { console.warn("JSON did not include any filters"); } if (metadata.displayDefaults) { - const keysToCheckFor = ["geoResolution", "colorBy", "distanceMeasure", "layout", "mapTriplicate", "selectedBranchLabel", 'sidebar']; - const expectedTypes = ["string", "string", "string", "string", "boolean", "string", 'string']; // eslint-disable-line no-multi-spaces + const keysToCheckFor = ["geoResolution", "colorBy", "distanceMeasure", "layout", "mapTriplicate", "selectedBranchLabel", 'sidebar', "showTransmissionLines"]; + const expectedTypes = ["string", "string", "string", "string", "boolean", "string", 'string', "boolean" ]; // eslint-disable-line for (let i = 0; i < keysToCheckFor.length; i += 1) { - if (metadata.displayDefaults[keysToCheckFor[i]]) { + if (Object.hasOwnProperty.call(metadata.displayDefaults, keysToCheckFor[i])) { if (typeof metadata.displayDefaults[keysToCheckFor[i]] === expectedTypes[i]) { // eslint-disable-line valid-typeof if (keysToCheckFor[i] === "sidebar") { if (metadata.displayDefaults[keysToCheckFor[i]] === "open") { @@ -631,10 +631,11 @@ const createMetadataStateFromJSON = (json) => { map_triplicate: "mapTriplicate", layout: "layout", sidebar: "sidebar", - panels: "panels" + panels: "panels", + transmission_lines: "showTransmissionLines" }; for (const [jsonKey, auspiceKey] of Object.entries(jsonKeyToAuspiceKey)) { - if (json.meta.display_defaults[jsonKey]) { + if (Object.prototype.hasOwnProperty.call(json.meta.display_defaults, jsonKey)) { metadata.displayDefaults[auspiceKey] = json.meta.display_defaults[jsonKey]; } }