-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature/user colors #584
Feature/user colors #584
Changes from all commits
3247637
0a98fdc
7a4fb7c
3f97eb0
5400f74
7e7df61
affe165
adbd51d
a6021ec
b020612
c52e95d
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ import { ViewerStatus } from "../viewer/types"; | |
import { | ||
changeTime, | ||
resetAgentSelectionsAndHighlights, | ||
setSelectedUIDisplayData, | ||
} from "../selection/actions"; | ||
import { setSimulariumController } from "../simularium/actions"; | ||
import { getSimulariumController } from "../simularium/selectors"; | ||
|
@@ -62,6 +63,7 @@ import { | |
CONVERT_FILE, | ||
RECEIVE_CONVERTED_FILE, | ||
CANCEL_CONVERSION, | ||
SET_DEFAULT_UI_DATA, | ||
} from "./constants"; | ||
import { | ||
ReceiveAction, | ||
|
@@ -638,6 +640,15 @@ const cancelConversionLogic = createLogic({ | |
type: CANCEL_CONVERSION, | ||
}); | ||
|
||
const setInitialSelectedUIData = createLogic({ | ||
process(deps: ReduxLogicDeps, dispatch) { | ||
const { action } = deps; | ||
const uiData = action.payload; | ||
dispatch(setSelectedUIDisplayData(uiData)); | ||
}, | ||
type: SET_DEFAULT_UI_DATA, | ||
}); | ||
Comment on lines
+643
to
+650
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. This logic looks like it just re-dispatches the triggering action with a different type? If not, what am I missing; if so, why not just use that action in place of the one that triggers this logic? 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. Your point is valid! Context: this was a larger PR, and I got the feedback that I should chunk things up in more bite size pieces. You're correct that this doesn't really need this logic yet, we can just call both I know because I have a crystal ball, that we are likely going to need this asynchronous logic because we won't know what happens first: parsing of the trajectory to derive This is a problem of my making! Trying to work backwards from bigger feature branches into smaller PRs can lead to issues like this. Maybe the defining of the subtasks is the real problem, as this whole PR is somewhat contrived and serves no purpose except to lay the groundwork for forthcoming code, so I wonder what is the greater sin: using this logic to set derived state, or correctly storing state that is never accessed in the first place. |
||
|
||
export default [ | ||
requestPlotDataLogic, | ||
loadLocalFile, | ||
|
@@ -650,4 +661,5 @@ export default [ | |
convertFileLogic, | ||
receiveConvertedFileLogic, | ||
cancelConversionLogic, | ||
setInitialSelectedUIData, | ||
]; |
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.
Still a bit bummed to see this synchronous state derivation code in a logic. Everything this code does would (I think) work just fine in a reducer branch, and would probably be more at home there, where it wouldn't have to re-dispatch a new action and immediately call
done
to clear out resources held byredux-logic
for what it assumes to be anasync
operation. That change is well out of scope for this PR though.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.
This seems like a good opportunity for a refactor. This logic was put in place during previous work on color changing, and its role has changed.
We can derive the new
UiDisplayData
and pass it intoredux
directly, redux never needs to handle theColorChange
. I am inclined to do this inModelPanel
instead of in the reducer because the pattern in this repo is for reducers to simply pass on their action payload without side effects.Adding (synchronous) logic to a reducer feels like breaking that pattern in a way that puts code in more places which is part of the pain of redux, for me at least. But I accept that this
redux-logic
is not the right place for it either.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.
Wrote a brief issue (#596 ) and will address in a separate PR.