-
Notifications
You must be signed in to change notification settings - Fork 273
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
fix(dashboard): stackgraph loses ws status when drawn #791
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 |
---|---|---|
|
@@ -42,6 +42,13 @@ export default () => { | |
if (!config.data || !graph.data || config.loading || graph.loading) { | ||
return <Spinner /> | ||
} | ||
if (message && message.type === "event") { | ||
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 is a good solution! The container is exactly the one that should be responsible for preparing the data for the component in this case. 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. Thank you very much! :) |
||
const nodeToUpdate = graph.data.nodes.find(node => node.key === (message.payload && message.payload["key"])) | ||
if (nodeToUpdate) { | ||
nodeToUpdate.status = message.name | ||
graph.data = { ...graph.data } | ||
} | ||
} | ||
|
||
let moreInfoPane: React.ReactNode = null | ||
if (selectedGraphNode && graph.data) { | ||
|
@@ -59,7 +66,6 @@ export default () => { | |
<Wrapper className="row"> | ||
<div className={moreInfoPane ? "col-xs-7 col-sm-7 col-md-8 col-lg-8 col-xl-8" : "col-xs"}> | ||
<Graph | ||
message={message} | ||
onGraphNodeSelected={selectGraphNode} | ||
selectedGraphNode={selectedGraphNode} | ||
layoutChanged={isSidebarOpen} | ||
|
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.
I originally added this because the websocket messages would trigger a re-render of the graph which, IIRC, was slow and choppy. But now it looks just fine! What's the secret?
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.
We use the function getNodeClass inside the drawChart and we only rendering it if only the graph has changed (by changed i mean changed its ref - look at graph.tsx there is this code:
if (message && message.type === "event") { const nodeToUpdate = graph.data.nodes.find(node => node.key === (message.payload && message.payload["key"])) if (nodeToUpdate) { nodeToUpdate.status = message.name graph.data = {...graph.data} } }
changing the graph.data ref will trigger the drawChart.
im not so sure what is the secret, i just think that its more logical this way and maybe the god of javascript like this more so he decided to pump up the performance xD