File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 483483 }
484484 customMenus = menus ;
485485 refreshMagic ( ) ;
486- if ( typeof scaffolding === "undefined" ) {
487- // Remove Menu Blocks that no Longer Exist
488- const allBlocks = ScratchBlocks . mainWorkspace . blockDB_ ;
489- const menuNames = Object . keys ( customMenus ) ;
490- for ( const [ key , block ] of Object . entries ( allBlocks ) ) {
486+
487+ // Remove Menu Blocks that no Longer Exist
488+ const menuNames = Object . keys ( customMenus ) ;
489+ if ( Scratch . gui ) Scratch . gui . getBlockly ( ) . then ( SB => {
490+ const allBlocks = SB . mainWorkspace . blockDB_ ;
491+ for ( const block of Object . values ( allBlocks ) ) {
491492 if ( block . type . startsWith ( "SP0zMenuMaker_menu_" ) ) {
492493 if ( menuNames . indexOf ( block . type . replace ( "SP0zMenuMaker_menu_" , "" ) ) === - 1 ) block . dispose ( ) ;
493494 }
494495 }
496+ } ) ;
497+ if ( typeof scaffolding === "undefined" ) {
498+ for ( const target of runtime . targets ) {
499+ const blockCache = target . blocks ;
500+ for ( const block of Object . values ( blockCache . _blocks ) ) {
501+ if (
502+ block . opcode . startsWith ( "SP0zMenuMaker_menu_" ) &&
503+ menuNames . indexOf ( block . opcode . replace ( "SP0zMenuMaker_menu_" , "" ) ) === - 1
504+ ) blockCache . deleteBlock ( block . id , true ) ;
505+ }
506+ }
495507 }
496508 } catch { alert ( "Couldnt Parse Imported Custom Menu JSON" ) }
497509 }
You can’t perform that action at this time.
0 commit comments