@@ -31,7 +31,7 @@ import {category as methodsCategory} from './methods_category';
3131
3232export function getToolboxJSON (
3333 opt_includeExportedBlocksFromProject : toolboxItems . ContentsType [ ] ,
34- shownPythonToolboxCategories : Set < string > ) {
34+ shownPythonToolboxCategories : Set < string > | null ) {
3535 const contents : toolboxItems . ContentsType [ ] = generatedToolbox . getToolboxCategories ( ) ;
3636 filterGeneratedCategories ( contents , shownPythonToolboxCategories ) ;
3737
@@ -81,7 +81,7 @@ export function getToolboxJSON(
8181}
8282
8383function filterGeneratedCategories (
84- contents : toolboxItems . ContentsType [ ] , shownPythonToolboxCategories : Set < string > ) {
84+ contents : toolboxItems . ContentsType [ ] , shownPythonToolboxCategories : Set < string > | null ) {
8585 contents . forEach ( ( item ) => {
8686 if ( item . kind === 'category' ) {
8787 const category = item as toolboxItems . Category ;
@@ -91,15 +91,15 @@ function filterGeneratedCategories(
9191 }
9292 if ( ( category as toolboxItems . PythonModuleCategory ) . moduleName ) {
9393 const moduleName = ( item as toolboxItems . PythonModuleCategory ) . moduleName ;
94- if ( ! shownPythonToolboxCategories . has ( moduleName ) ) {
94+ if ( shownPythonToolboxCategories != null && ! shownPythonToolboxCategories . has ( moduleName ) ) {
9595 if ( category . contents ) {
9696 removeBlocksAndSeparators ( category . contents ) ;
9797 }
9898 }
9999 }
100100 if ( ( category as toolboxItems . PythonClassCategory ) . className ) {
101101 const className = ( item as toolboxItems . PythonClassCategory ) . className ;
102- if ( ! shownPythonToolboxCategories . has ( className ) ) {
102+ if ( shownPythonToolboxCategories != null && ! shownPythonToolboxCategories . has ( className ) ) {
103103 if ( category . contents ) {
104104 removeBlocksAndSeparators ( category . contents ) ;
105105 }
@@ -123,7 +123,7 @@ function removeBlocksAndSeparators(contents: toolboxItems.ContentsType[]) {
123123}
124124
125125function removeEmptyCategories (
126- contents : toolboxItems . ContentsType [ ] , shownPythonToolboxCategories : Set < string > ) {
126+ contents : toolboxItems . ContentsType [ ] , shownPythonToolboxCategories : Set < string > | null ) {
127127 let i = 0 ;
128128 while ( i < contents . length ) {
129129 let remove = false ;
@@ -137,7 +137,7 @@ function removeEmptyCategories(
137137 }
138138 if ( category . contents &&
139139 category . contents . length == 0 &&
140- ! shownPythonToolboxCategories . has ( fullCategoryName ) ) {
140+ shownPythonToolboxCategories != null && ! shownPythonToolboxCategories . has ( fullCategoryName ) ) {
141141 remove = true ;
142142 }
143143 }
0 commit comments