-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Narratives bug #736
Merged
Merged
Narratives bug #736
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kairstenfay
force-pushed
the
narratives_bug
branch
from
July 6, 2019 01:39
019c906
to
f148f97
Compare
Because the `updateOnMoveEnd` function only runs code inside the conditional `if (d3elems) {}`, refactor to create a `if (!d3elems) {}` guard statements and unindent the code within the function.
In `maybeUpdateDemesAndTransmissions()`, the variable `haveData` was not always a boolean as was seemingly intended by its naming and usage. Change one of the values in its declaration to evaluate to a boolean by prefixing `!!`. Now `!!nextProps.nodeColors` evaluates to `true` or `false` instead of a list or `false`.
Previously, in the function `maybeUpdateDemesAndTransmissions()` (part of the Map component), there was a large, indented code block inside of a conditional checking for truthiness in `colorOrVisibilityChange && haveData`. Because changes only occurred if this conditional was true, refactor it so that the conditional is now a guard statement. If the conditional evaluates to false, exit the function. Now the bulk of the code is not indented.
Reduce the level of indendation of the bulk of the code in the function `setupTransmissionData` by refactoring two of the conditional checks into guard statements. This change reduces the cognitive load required to read and understand this function.
Refactor the function `setupDemeData` for better readability by reducing the level of indentation of the code. This commit converts two conditional checks into guard statements that exit the `forEach` loop if each condition is not met. Also removes an explicit `boolean === true` check in favor of `boolean`.
Shorten a conditional by casting the string to lower case.
Refactor the `updateTransmissionDataColAndVis` function to reduce the level of indendation of the code. Convert the conditional checks to guard statements that exist the `forEach` loop if the condition is not met.
Logs an error in the function `updateVisibility' if `d3elems` is undefined. Co-authored-by: James Hadfield <jhadfiel@fredhutch.org>
Previously, when the geo resolution would change, `drawDemesAndTransmissions` would not necessarily be called, often causing data on the map to not load at all between queries. James also did some work here to correct the deme and transmission data that were being loaded on each narrative page change. This commit further complicates the map code, but is necessary to fix this bug. It is a prime candidate for refactoring in #735 Co-authored-by: James Hadfield <jh22@sanger.ac.uk> Co-authored-by: Jover Lee <joverlee521@gmail.com>
jameshadfield
force-pushed
the
narratives_bug
branch
from
July 9, 2019 03:03
f148f97
to
30299e5
Compare
Thanks @kairstenfay and @joverlee521 🎉 I've cherry-picked the commits onto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the bugs described in #722 and #731 (and maybe others?)
The last couple of commits are a WIP that need refactoring, but I won't have time to get back to it for a few weeks.
It represents a joint effort between @joverlee521, @jameshadfield and me.