From c565b5a08265755507840d3e3272fb75a9a59a6b Mon Sep 17 00:00:00 2001 From: Christopher Suchanek Date: Fri, 27 Mar 2020 13:59:27 -0700 Subject: [PATCH 1/2] Don't show sampling date ranges if nothing was sampled --- src/components/info/info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/info/info.js b/src/components/info/info.js index 05bc818c2..1e1304a31 100644 --- a/src/components/info/info.js +++ b/src/components/info/info.js @@ -70,7 +70,7 @@ export const createSummary = (mainTreeNumTips, nodes, filters, visibility, visib let summary = ""; /* text returned from this function */ /* Number of genomes & their date range */ - if (branchLengthsToDisplay !== "divOnly") { + if (branchLengthsToDisplay !== "divOnly" && nSelectedSamples > 0) { summary += t( "Showing {{x}} of {{y}} genomes sampled between {{from}} and {{to}}.", { From 73a7df8114b5e9a8911eeee05c2f47dec4978559 Mon Sep 17 00:00:00 2001 From: Christopher Suchanek Date: Fri, 27 Mar 2020 14:08:44 -0700 Subject: [PATCH 2/2] fixed reduce function to support 1 element list --- src/util/treeVisibilityHelpers.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/treeVisibilityHelpers.js b/src/util/treeVisibilityHelpers.js index ac8fecfa6..96f024868 100644 --- a/src/util/treeVisibilityHelpers.js +++ b/src/util/treeVisibilityHelpers.js @@ -7,9 +7,7 @@ export const getVisibleDateRange = (nodes, visibility) => nodes .filter((node, idx) => (visibility[idx] === NODE_VISIBLE && !node.hasChildren)) .reduce((acc, node) => { const nodeDate = getTraitFromNode(node, "num_date"); - if (nodeDate && nodeDate < acc[0]) return [nodeDate, acc[1]]; - if (nodeDate && nodeDate > acc[1]) return [acc[0], nodeDate]; - return acc; + return nodeDate ? [Math.min(nodeDate, acc[0]), Math.max(nodeDate, acc[1])] : acc; }, [100000, -100000]); export const strainNameToIdx = (nodes, name) => {