@@ -59,6 +59,11 @@ type ComponentExtraState = {
5959 // If staticFunctionName is not present, generate the constructor.
6060 staticFunctionName ?: string ,
6161 params ?: ConstructorArg [ ] ,
62+ /**
63+ * The module type. Note that this is only present when blocks are created for the toolbox. It is not
64+ * saved to the blocks file.
65+ */
66+ moduleType ? : storageModule . ModuleType ,
6267}
6368
6469export type ComponentBlock = Blockly . Block & ComponentMixin ;
@@ -137,13 +142,13 @@ const COMPONENT = {
137142 } ) ;
138143 } ) ;
139144 }
140- this . updateBlock_ ( ) ;
145+ this . updateBlock_ ( extraState ) ;
141146 } ,
142147 /**
143148 * Update the block to reflect the newly loaded extra state.
144149 */
145- updateBlock_ : function ( this : ComponentBlock ) : void {
146- const moduleType = getModuleTypeForWorkspace ( this . workspace ) ;
150+ updateBlock_ : function ( this : ComponentBlock , extraState : ComponentExtraState ) : void {
151+ const moduleType = extraState . moduleType ? extraState . moduleType : getModuleTypeForWorkspace ( this . workspace ) ;
147152 if ( moduleType === storageModule . ModuleType . ROBOT ) {
148153 // Add input sockets for the arguments.
149154 for ( let i = 0 ; i < this . mrcArgs . length ; i ++ ) {
@@ -297,6 +302,7 @@ function createComponentBlock(
297302 //TODO(ags): Remove this because we know what the constructor name is
298303 staticFunctionName : constructorData . functionName ,
299304 params : [ ] ,
305+ moduleType : moduleType ,
300306 } ;
301307 const fields : { [ key : string ] : any } = { } ;
302308 fields [ FIELD_NAME ] = componentName ;
0 commit comments