-
Notifications
You must be signed in to change notification settings - Fork 162
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
Improve tree performance for trees with over 4000 tips #1880
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as types from "../actions/types"; | ||
|
||
/** | ||
* Performance toggles (reduxState.controls.performanceToggles) represent flags | ||
* for which we enable/disable certain functionality in Auspice. These flags | ||
* shouldn't be depended on, i.e. Auspice should work just fine without them | ||
* (but may be a little slow). | ||
*/ | ||
|
||
|
||
export const performanceToggles = (_store) => (next) => (action) => { | ||
let modifiedAction; | ||
switch (action.type) { | ||
case types.URL_QUERY_CHANGE_WITH_COMPUTED_STATE: /* fallthrough */ | ||
case types.CLEAN_START: { | ||
victorlin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
modifiedAction = {...action}; | ||
modifiedAction.controls.performanceToggles = calculate(action) | ||
} | ||
} | ||
return next(modifiedAction || action); // send action to other middleware / reducers | ||
}; | ||
|
||
function calculate({tree}) { | ||
const toggles = new Map(); | ||
const totalTipCount = tree?.nodes?.[0]?.fullTipCount; | ||
toggles.set("skipTreeAnimation", totalTipCount > 4000); | ||
Comment on lines
+25
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: 0862223
I thought about something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In canonical redux this would be straightforward as middleware has access to the old state and because we use fat actions it also can see the new state. But as we modify the |
||
return toggles; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Toggle" in the name confused me at first since all other usages of "toggle" refer to booleans in Redux that are flipped on dispatch. This is instead flipped by preset conditions. How about "performance optimizations"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 will change to
performanceFlags