Skip to content
Snippets Groups Projects
Commit 54a3f376 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Use the improved extension status button API

parent 0a41a0c6
No related branches found
No related tags found
No related merge requests found
...@@ -212,6 +212,8 @@ class Blocks extends React.Component { ...@@ -212,6 +212,8 @@ class Blocks extends React.Component {
this.props.vm.addListener('targetsUpdate', this.onTargetsUpdate); this.props.vm.addListener('targetsUpdate', this.onTargetsUpdate);
this.props.vm.addListener('EXTENSION_ADDED', this.handleExtensionAdded); this.props.vm.addListener('EXTENSION_ADDED', this.handleExtensionAdded);
this.props.vm.addListener('BLOCKSINFO_UPDATE', this.handleBlocksInfoUpdate); this.props.vm.addListener('BLOCKSINFO_UPDATE', this.handleBlocksInfoUpdate);
this.props.vm.addListener('PERIPHERAL_CONNECTED', this.handleStatusButtonUpdate);
this.props.vm.addListener('PERIPHERAL_ERROR', this.handleStatusButtonUpdate);
} }
detachVM () { detachVM () {
this.props.vm.removeListener('SCRIPT_GLOW_ON', this.onScriptGlowOn); this.props.vm.removeListener('SCRIPT_GLOW_ON', this.onScriptGlowOn);
...@@ -223,6 +225,8 @@ class Blocks extends React.Component { ...@@ -223,6 +225,8 @@ class Blocks extends React.Component {
this.props.vm.removeListener('targetsUpdate', this.onTargetsUpdate); this.props.vm.removeListener('targetsUpdate', this.onTargetsUpdate);
this.props.vm.removeListener('EXTENSION_ADDED', this.handleExtensionAdded); this.props.vm.removeListener('EXTENSION_ADDED', this.handleExtensionAdded);
this.props.vm.removeListener('BLOCKSINFO_UPDATE', this.handleBlocksInfoUpdate); this.props.vm.removeListener('BLOCKSINFO_UPDATE', this.handleBlocksInfoUpdate);
this.props.vm.removeListener('PERIPHERAL_CONNECTED', this.handleStatusButtonUpdate);
this.props.vm.removeListener('PERIPHERAL_ERROR', this.handleStatusButtonUpdate);
} }
updateToolboxBlockValue (id, value) { updateToolboxBlockValue (id, value) {
...@@ -357,8 +361,8 @@ class Blocks extends React.Component { ...@@ -357,8 +361,8 @@ class Blocks extends React.Component {
handleConnectionModalClose () { handleConnectionModalClose () {
this.setState({connectionModal: null}); this.setState({connectionModal: null});
} }
handleStatusButtonUpdate (extensionId, status) { handleStatusButtonUpdate () {
this.ScratchBlocks.updateStatusButton(this.workspace, extensionId, status); this.ScratchBlocks.refreshStatusButtons(this.workspace);
} }
handlePromptCallback (input, optionSelection) { handlePromptCallback (input, optionSelection) {
this.state.prompt.callback(input, optionSelection, this.state.prompt.callback(input, optionSelection,
......
...@@ -56,13 +56,13 @@ class ConnectionModal extends React.Component { ...@@ -56,13 +56,13 @@ class ConnectionModal extends React.Component {
this.props.onCancel(); this.props.onCancel();
} }
handleError () { handleError () {
this.props.onStatusButtonUpdate(this.props.extensionId, 'not ready'); this.props.onStatusButtonUpdate();
this.setState({ this.setState({
phase: PHASES.error phase: PHASES.error
}); });
} }
handleConnected () { handleConnected () {
this.props.onStatusButtonUpdate(this.props.extensionId, 'ready'); this.props.onStatusButtonUpdate();
this.setState({ this.setState({
phase: PHASES.connected phase: PHASES.connected
}); });
......
...@@ -208,5 +208,12 @@ export default function (vm) { ...@@ -208,5 +208,12 @@ export default function (vm) {
return monitoredBlock ? monitoredBlock.isMonitored : false; return monitoredBlock ? monitoredBlock.isMonitored : false;
}; };
ScratchBlocks.FlyoutExtensionCategoryHeader.getExtensionState = function (extensionId) {
if (vm.getPeripheralIsConnected(extensionId)) {
return ScratchBlocks.StatusButtonState.READY;
}
return ScratchBlocks.StatusButtonState.NOT_READY;
};
return ScratchBlocks; return ScratchBlocks;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment