-
Notifications
You must be signed in to change notification settings - Fork 47
Led integration between webview and python api #192
Led integration between webview and python api #192
Conversation
…github.com/microsoft/vscode-python-devicesimulator into users/t-anmah/frontend-backend-integration
super(props); | ||
} | ||
componentDidMount() { | ||
const svgElement = this.svgRef.current; |
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.
null check missing this.svgRef && this.svgRef.current
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've typed svgRef as always defined since I create it in the same class before the component mounts
} | ||
} | ||
componentDidUpdate() { | ||
if (this.svgRef.current) { |
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.
null check missing this.svgRef
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.
same here, svgRef should always be defined
) => { | ||
for (let j = 0; j < leds.length; j++) { | ||
for (let i = 0; i < leds[0].length; i++) { | ||
const ledElement = ledRefs[j][i].current; |
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 would do a null check for ledRefs here just to be sure
} | ||
} | ||
}; | ||
const setupLed = (ledElement: SVGRectElement, brightness: number) => { |
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.
nit: typo SVGReactElement, can you update all the instances
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.
SVGRectElement are referencing to tsx svg rect elements. For example,
@@ -0,0 +1,9 @@ | |||
interface vscode { | |||
postMessage(message: any): void; |
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.
Is it worth typifying this?
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 interface links to the vscode api which has any type. The only place where we call this specific interface is in sendMessage (with generic typing in the following comment you made)
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.
LGTM! Great job everyone 🥇
src/common/utils.py
Outdated
global previous_state | ||
|
||
message = create_message(state, device_name) | ||
|
||
if state != previous_state: |
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.
Thanks for addressing the comment!
But now this part might not work as expected, right?
I would take the state updating logic and put it in this method (or in a function and call that function here).
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.
Thanks! I just abstracted out the state updating and made the process two function calls :).
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.
Awesome!
One more thing, now send_to_simulator
and debug_show
mutate the input parameters. It would be easier for a developer if they can use these functions without worrying about any unintended consequences.
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.
ok, tried to fix it in the last commit :)
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.
Almost perfect!
Now this check will always return true if state != previous_state:
. Perhaps use state_copy
instead of state
?
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.
oops! fixed
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.
*nit*
I would change the name to updated_state
from state_copy
. Up to you!
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.
fixed!
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.
Looks good. Amazing work. 💯 |
…github.com/microsoft/vscode-python-devicesimulator into users/t-anmah/frontend-backend-integration
Description:
Python code is compiled and can send messages to typescript api then to the webview.
Type of change
Please delete options that are not relevant.
Limitations:
Please describe limitations of this PR
Testing:
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
npm run format
and passes the checks innpm run check