From 5202755231cb95e66434da194ea79078de2313ec Mon Sep 17 00:00:00 2001 From: James Hadfield Date: Fri, 19 Mar 2021 09:14:31 +1300 Subject: [PATCH] Ensure metadata.display_defaults exists A bug was introduced in PR #1280 where datasets which did not define `metadata.display_defaults` would crash, as the code assumed its existence. This property is optional in the dataset JSON. This commit ensures `display_defaults` exists in redux state after a dataset is loaded, thus allowing code to rely on its presence. This was preferred to checking for `display_defaults` in (all) the relevant sections of code, now and in future. (Using TypeScript, or expanding our smoke tests, would be approaches to avoiding these kinds of bugs in future.) --- CHANGELOG.md | 4 ++-- src/actions/recomputeReduxState.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80dcdd563..9c753f744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ title: Changelog --- -## version 2.24.0 - 2021/03/17 - +* [bugfix] Fixes a bug introduced in v2.24.0 where certain datasets wouldn't load +## version 2.24.0 - 2021/03/17 * Frequencies are no longer normalized when the data is lacking. See [PR 1278](https://github.com/nextstrain/auspice/pull/1278) for more. diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index d479ff0b4..a1fc7a42b 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -241,6 +241,8 @@ const modifyStateViaMetadata = (state, metadata) => { } } } + } else { + metadata.displayDefaults = {}; // allows code to rely on `displayDefaults` existing } if (metadata.panels) {