Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
Modify format of messages from vscode api to python
Browse files Browse the repository at this point in the history
  • Loading branch information
xnkevinnguyen committed Feb 10, 2020
1 parent 1266d12 commit 86610b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ export async function activate(context: vscode.ExtensionContext) {
// Handle messages from webview
messageListener = currentPanel.webview.onDidReceiveMessage(
message => {
const messageJson = JSON.stringify(message.text);
const messageJson = JSON.stringify({
active_device: currentActiveDevice,
state: message.text,
});
switch (message.command) {
case WEBVIEW_MESSAGES.BUTTON_PRESS:
// Send input to the Python process
Expand Down
1 change: 0 additions & 1 deletion src/view/components/cpx/CpxSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class Simulator extends React.Component<{}, IState> {

protected togglePlayClick() {
sendMessage("play-simulator", {
active_device: CONSTANTS.DEVICE_NAME.CPX,
selected_file: this.state.selected_file,
state: !this.state.play_button,
});
Expand Down
6 changes: 1 addition & 5 deletions src/view/components/microbit/MicrobitSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export class MicrobitSimulator extends React.Component<any, IState> {
}
protected togglePlayClick = () => {
sendMessage(WEBVIEW_MESSAGES.TOGGLE_PLAY_STOP, {
active_device: CONSTANTS.DEVICE_NAME.MICROBIT,
selected_file: this.state.selected_file,
state: !this.state.play_button,
});
Expand Down Expand Up @@ -154,10 +153,7 @@ export class MicrobitSimulator extends React.Component<any, IState> {
};
break;
}
sendMessage(WEBVIEW_MESSAGES.BUTTON_PRESS, {
active_device: DEVICE_LIST_KEY.MICROBIT,
state: newButtonState,
});
sendMessage(WEBVIEW_MESSAGES.BUTTON_PRESS, newButtonState);
this.setState({
microbit: {
...this.state.microbit,
Expand Down

0 comments on commit 86610b6

Please sign in to comment.