File tree Expand file tree Collapse file tree
application/worker/store/modules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -475,6 +475,36 @@ const actions = {
475475 }
476476
477477 return ;
478+ } ,
479+
480+ async removeActiveModule ( { commit } , { moduleId, writeToSwap } ) {
481+ const writeTo = writeToSwap ? swap : state ;
482+
483+ const module = writeTo . active [ moduleId ] ;
484+ const { meta } = module ;
485+
486+ if ( ! module ) {
487+ throw new Error ( `No module with id "${ moduleId } " found` ) ;
488+ }
489+
490+ const metaInputIds = [
491+ meta . alphaInputId ,
492+ meta . compositeOperationInputId ,
493+ meta . enabledInputId
494+ ] ;
495+ const moduleProperties = Object . values ( module . $props ) . map ( prop => prop . id ) ;
496+ const inputIds = [ ...moduleProperties , ...metaInputIds ] ;
497+
498+ for ( let i = 0 , len = inputIds . length ; i < len ; i ++ ) {
499+ const inputId = inputIds [ i ] ;
500+
501+ await store . dispatch ( "inputs/removeInputLink" , {
502+ inputId,
503+ writeToSwap
504+ } ) ;
505+ }
506+
507+ commit ( "REMOVE_ACTIVE_MODULE" , { moduleId, writeToSwap } ) ;
478508 }
479509} ;
480510
Original file line number Diff line number Diff line change @@ -77,10 +77,11 @@ export default {
7777 window .dispatchEvent (new Event (" resize" ));
7878 },
7979
80- beforeDestroy () {
81- this .$modV .store .commit (" modules/REMOVE_ACTIVE_MODULE " , {
80+ async beforeDestroy () {
81+ await this .$modV .store .dispatch (" modules/removeActiveModule " , {
8282 moduleId: this .id
8383 });
84+
8485 this .$modV .store .commit (" outputs/REMOVE_AUXILLARY" , this .outputId );
8586 this .$modV .store .commit (" groups/REMOVE_MODULE_FROM_GROUP" , {
8687 groupId: this .groupId ,
Original file line number Diff line number Diff line change @@ -478,7 +478,7 @@ export default {
478478 groupId
479479 });
480480
481- this .$modV .store .commit (" modules/REMOVE_ACTIVE_MODULE " , {
481+ this .$modV .store .dispatch (" modules/removeActiveModule " , {
482482 moduleId
483483 });
484484 },
You can’t perform that action at this time.
0 commit comments