Fixups from code review

- Remove WeDo 2 extension from the runtime's default block packages list
- The WeDo 2.0 extension now calls its own `connect` method on startup

I also renamed `EXTENSION_NAME` to `EXTENSION_ID` for consistency with
the rest of the extension system.
This commit is contained in:
Christopher Willis-Ford 2017-10-06 09:36:27 -07:00
parent b6727a766f
commit 7297341c51
2 changed files with 6 additions and 7 deletions

View file

@ -373,9 +373,9 @@ const TiltDirection = {
class Scratch3WeDo2Blocks {
/**
* @return {string} - the name of this extension.
* @return {string} - the ID of this extension.
*/
static get EXTENSION_NAME () {
static get EXTENSION_ID () {
return 'wedo2';
}
@ -397,7 +397,7 @@ class Scratch3WeDo2Blocks {
*/
this.runtime = runtime;
this.runtime.HACK_WeDo2Blocks = this;
this.connect();
}
/**
@ -405,7 +405,7 @@ class Scratch3WeDo2Blocks {
*/
getInfo () {
return {
id: 'wedo2',
id: Scratch3WeDo2Blocks.EXTENSION_ID,
name: 'WeDo 2.0',
blocks: [
{
@ -586,7 +586,7 @@ class Scratch3WeDo2Blocks {
}
const deviceManager = this.runtime.ioDevices.deviceManager;
const finder = this._finder =
deviceManager.searchAndConnect(Scratch3WeDo2Blocks.EXTENSION_NAME, WeDo2.DEVICE_TYPE);
deviceManager.searchAndConnect(Scratch3WeDo2Blocks.EXTENSION_ID, WeDo2.DEVICE_TYPE);
this._finder.promise.then(
socket => {
if (this._finder === finder) {

View file

@ -23,8 +23,7 @@ const defaultBlockPackages = {
scratch3_sound: require('../blocks/scratch3_sound'),
scratch3_sensing: require('../blocks/scratch3_sensing'),
scratch3_data: require('../blocks/scratch3_data'),
scratch3_procedures: require('../blocks/scratch3_procedures'),
scratch3_wedo2: require('../blocks/scratch3_wedo2')
scratch3_procedures: require('../blocks/scratch3_procedures')
};
/**