Skip to content

Commit

Permalink
Load measurements JSON with createStateFromQueryOrJSONs
Browse files Browse the repository at this point in the history
Updating to support upcoming changes in Auspice from
<nextstrain/auspice#1881>
  • Loading branch information
joverlee521 committed Nov 5, 2024
1 parent 736b399 commit 4150c56
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions auspice_client_customisation/handleDroppedFiles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createStateFromQueryOrJSONs } from "@auspice/actions/recomputeReduxState";
import { errorNotification, warningNotification } from "@auspice/actions/notifications";
import { Dataset, addEndOfNarrativeBlock, getDatasetNamesFromUrl } from "@auspice/actions/loadData";
import { parseMeasurementsJSON } from "@auspice/actions/measurements";
import { parseMarkdownNarrativeFile } from "@auspice/util/parseNarrative";
import { parseMarkdown } from "@auspice/util/parseMarkdown";
import { isAcceptedFileType as isAuspiceAcceptedFileType } from "@auspice/actions/filesDropped/constants";
Expand Down Expand Up @@ -123,15 +122,7 @@ async function collectDatasets(dispatch, files) {
filesSeen.add(nameLower);
const mainNameLower = nameLower.replace(`_${sidecarSuffix}.json`, '.json');
if (datasets[mainNameLower]) {
// Parse measurements sidecars separately here.
// See https://github.com/nextstrain/auspice/pull/1663
if (sidecarPropName === 'measurements') {
datasets[mainNameLower][sidecarPropName] = readFile(file)
.then((json) => parseMeasurementsJSON(json))
.catch((err) => console.error("Failed to read and parse measurements sidecar", err));
} else {
datasets[mainNameLower][sidecarPropName] = readFile(file);
}
datasets[mainNameLower][sidecarPropName] = readFile(file);
logs.push(`Read ${file.name} as a sidecar file of ${datasets[mainNameLower].name}`);
} else {
dispatch(errorNotification({
Expand Down Expand Up @@ -204,6 +195,7 @@ async function loadDatasets(dispatch, datasets, narrative) {
pathnameShouldBe: "",
...createStateFromQueryOrJSONs({
json: dataset1.main,
measurementsData: dataset1.measurements ? (await dataset1.measurements) : undefined,
secondTreeDataset: dataset2 ? dataset2.main : null,
query: {},
narrativeBlocks: narrative,
Expand Down

0 comments on commit 4150c56

Please sign in to comment.