Skip to content

Commit

Permalink
download: use the node.shell.inView property
Browse files Browse the repository at this point in the history
The `node.inView` property is a temporary hold for the node's inView
property to be able to zoom in on specific branches before the
D3 PhyloTree has been constructed.

Once the D3 PhyloTree has been constructed, the inView property is
available through `node.shell.inView`. This is the property that gets
updated by `applyInViewNodesToTree` whenever the user interacts with
any zooming functionality on the tree. The temporary `node.inView`
property will never be updated and thus only represents the initial
state of the node when the tree was first loaded.

Therefore, any downstream uses of the inView property should be using
the `node.shell.inView` property.
  • Loading branch information
joverlee521 committed Jul 27, 2023
1 parent 3e3f8bd commit 8304cdf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/download/downloadButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function Button({name, description, icon, onClick}) {

function getNumUniqueAuthors(nodes, nodeVisibilities) {
const authors = new Set(nodes
.filter((n, i) => nodeVisibilities[i] === NODE_VISIBLE && n.inView)
.filter((n, i) => nodeVisibilities[i] === NODE_VISIBLE && n.shell.inView)
.map((n) => getFullAuthorInfoFromNode(n))
.filter((a) => a && a.value)
.map((a) => a.value)
Expand Down
8 changes: 4 additions & 4 deletions src/components/download/helperFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const treeToNewick = (tree, temporal, internalNodeNames=false, nodeAnnotation=()
const getXVal = temporal ? (n) => getTraitFromNode(n, "num_date") : getDivFromNode;

function recurse(node, parentX) {
if (!node.inView || tree.visibility[node.arrayIdx]!==NODE_VISIBLE) {
if (!node.shell.inView || tree.visibility[node.arrayIdx]!==NODE_VISIBLE) {
return "";
}
if (node.hasChildren) {
Expand Down Expand Up @@ -176,7 +176,7 @@ export const authorTSV = (dispatch, filePrefix, tree) => {
const UNKNOWN = "unknown";
const info = {};
tree.nodes
.filter((n, i) => tree.visibility[i] === NODE_VISIBLE && n.inView)
.filter((n, i) => tree.visibility[i] === NODE_VISIBLE && n.shell.inView)
.filter((n) => !n.hasChildren).forEach((n) => {
const author = getFullAuthorInfoFromNode(n);
if (!author) return;
Expand Down Expand Up @@ -221,7 +221,7 @@ export const strainTSV = (dispatch, filePrefix, nodes, nodeVisibilities) => {
for (const [i, node] of nodes.entries()) {
if (node.hasChildren) continue; /* we only consider tips */

if (nodeVisibilities[i] !== NODE_VISIBLE || !node.inView) {
if (nodeVisibilities[i] !== NODE_VISIBLE || !node.shell.inView) {
continue;
}

Expand Down Expand Up @@ -313,7 +313,7 @@ export const acknowledgmentsTSV = (dispatch, filePrefix, nodes, nodeVisibilities
for (const [i, node] of nodes.entries()) {
if (node.hasChildren) continue; /* we only consider tips */

if (nodeVisibilities[i] !== NODE_VISIBLE || !node.inView) {
if (nodeVisibilities[i] !== NODE_VISIBLE || !node.shell.inView) {
continue;
}

Expand Down

0 comments on commit 8304cdf

Please sign in to comment.