@@ -110,18 +110,15 @@ export function createCommonActions(self: InstanceBaseExt<WingConfig>): Companio
110110 callback : async ( event ) => {
111111 const sel = event . options . sel as string
112112 const cmd = ActionUtil . getScribblelightCommand ( sel , getNodeNumber ( event , 'sel' ) )
113- const val = ActionUtil . getNumber ( event , 'led' )
114- const currentVal = StateUtil . getBooleanFromState ( cmd , state )
115- if ( val < 2 ) {
116- send ( cmd , val )
117- } else {
118- send ( cmd , Number ( ! currentVal ) )
119- }
113+ const val = ActionUtil . getSetOrToggleValue ( cmd , ActionUtil . getNumber ( event , 'led' ) , state )
114+ send ( cmd , val )
120115 } ,
121116 subscribe : ( event ) => {
122- const sel = event . options . sel as string
123- const cmd = ActionUtil . getScribblelightCommand ( sel , getNodeNumber ( event , 'sel' ) )
124- ensureLoaded ( cmd )
117+ if ( event . options . led ?? 0 > 2 ) {
118+ const sel = event . options . sel as string
119+ const cmd = ActionUtil . getScribblelightCommand ( sel , getNodeNumber ( event , 'sel' ) )
120+ ensureLoaded ( cmd )
121+ }
125122 } ,
126123 } ,
127124 [ CommonActions . SetScribbleLightColor ] : {
@@ -261,18 +258,15 @@ export function createCommonActions(self: InstanceBaseExt<WingConfig>): Companio
261258 callback : async ( event ) => {
262259 const sel = event . options . sel as string
263260 const cmd = ActionUtil . getMuteCommand ( sel , getNodeNumber ( event , 'sel' ) )
264- const val = ActionUtil . getNumber ( event , 'mute' )
265- const currentVal = StateUtil . getBooleanFromState ( cmd , state )
266- if ( val < 2 ) {
267- send ( cmd , val )
268- } else {
269- send ( cmd , Number ( ! currentVal ) )
270- }
261+ const val = ActionUtil . getSetOrToggleValue ( cmd , ActionUtil . getNumber ( event , 'mute' ) , state )
262+ send ( cmd , val )
271263 } ,
272264 subscribe : ( event ) => {
273- const sel = event . options . sel as string
274- const cmd = ActionUtil . getMuteCommand ( sel , getNodeNumber ( event , 'sel' ) )
275- ensureLoaded ( cmd )
265+ if ( event . options . sel ?? 0 > 2 ) {
266+ const sel = event . options . sel as string
267+ const cmd = ActionUtil . getMuteCommand ( sel , getNodeNumber ( event , 'sel' ) )
268+ ensureLoaded ( cmd )
269+ }
276270 } ,
277271 } ,
278272 ////////////////////////////////////////////////////////////////
@@ -474,18 +468,15 @@ export function createCommonActions(self: InstanceBaseExt<WingConfig>): Companio
474468 callback : async ( event ) => {
475469 const sel = event . options . sel as string
476470 const cmd = ActionUtil . getSoloCommand ( sel , getNodeNumber ( event , 'sel' ) )
477- const val = ActionUtil . getNumber ( event , 'solo' )
478- const currentVal = StateUtil . getBooleanFromState ( cmd , state )
479- if ( val < 2 ) {
480- send ( cmd , val )
481- } else {
482- send ( cmd , Number ( ! currentVal ) )
483- }
471+ const val = ActionUtil . getSetOrToggleValue ( cmd , ActionUtil . getNumber ( event , 'solo' ) , state )
472+ send ( cmd , val )
484473 } ,
485474 subscribe : ( event ) => {
486- const sel = event . options . sel as string
487- const cmd = ActionUtil . getSoloCommand ( sel , getNodeNumber ( event , 'sel' ) )
488- ensureLoaded ( cmd )
475+ if ( event . options . sel ?? 0 > 2 ) {
476+ const sel = event . options . sel as string
477+ const cmd = ActionUtil . getSoloCommand ( sel , getNodeNumber ( event , 'sel' ) )
478+ ensureLoaded ( cmd )
479+ }
489480 } ,
490481 } ,
491482 [ CommonActions . ClearSolo ] : {
@@ -758,23 +749,16 @@ export function createCommonActions(self: InstanceBaseExt<WingConfig>): Companio
758749 callback : async ( event ) => {
759750 const sel = event . options . src as string
760751 const cmd = ActionUtil . getSendMuteCommand ( sel , getNodeNumber ( event , 'src' ) , getNodeNumber ( event , 'dest' ) )
761- const val = ActionUtil . getNumber ( event , 'mute' )
762- const currentVal = StateUtil . getBooleanFromState ( cmd , state )
763752 // The Send mutes need to be sent inverted becauxe it is an 'on' command
764- if ( val >= 2 ) {
765- send ( cmd , Number ( ! currentVal ) )
766- } else {
767- if ( val < 1 ) {
768- send ( cmd , 1 )
769- } else {
770- send ( cmd , 0 )
771- }
772- }
753+ const val = Number ( ! ActionUtil . getSetOrToggleValue ( cmd , ActionUtil . getNumber ( event , 'mute' ) , state ) )
754+ send ( cmd , val )
773755 } ,
774756 subscribe : ( event ) => {
775- const sel = event . options . sel as string
776- const cmd = ActionUtil . getSendMuteCommand ( sel , getNodeNumber ( event , 'src' ) , getNodeNumber ( event , 'dest' ) )
777- ensureLoaded ( cmd )
757+ if ( event . options . sel ?? 0 > 2 ) {
758+ const sel = event . options . sel as string
759+ const cmd = ActionUtil . getSendMuteCommand ( sel , getNodeNumber ( event , 'src' ) , getNodeNumber ( event , 'dest' ) )
760+ ensureLoaded ( cmd )
761+ }
778762 } ,
779763 } ,
780764 ////////////////////////////////////////////////////////////////
@@ -897,23 +881,16 @@ export function createCommonActions(self: InstanceBaseExt<WingConfig>): Companio
897881 callback : async ( event ) => {
898882 const sel = event . options . src as string
899883 const cmd = ActionUtil . getMainSendMuteCommand ( sel , getNodeNumber ( event , 'src' ) , getNodeNumber ( event , 'dest' ) )
900- const val = ActionUtil . getNumber ( event , 'mute' )
901- const currentVal = StateUtil . getBooleanFromState ( cmd , state )
902- // The Main Send mutes need to be sent inverted becauxe it is an 'on' command
903- if ( val >= 2 ) {
904- send ( cmd , Number ( ! currentVal ) )
905- } else {
906- if ( val < 1 ) {
907- send ( cmd , 1 )
908- } else {
909- send ( cmd , 0 )
910- }
911- }
884+ // The Send mutes need to be sent inverted becauxe it is an 'on' command
885+ const val = Number ( ! ActionUtil . getSetOrToggleValue ( cmd , ActionUtil . getNumber ( event , 'mute' ) , state ) )
886+ send ( cmd , val )
912887 } ,
913888 subscribe : ( event ) => {
914- const sel = event . options . sel as string
915- const cmd = ActionUtil . getMainSendMuteCommand ( sel , getNodeNumber ( event , 'src' ) , getNodeNumber ( event , 'dest' ) )
916- ensureLoaded ( cmd )
889+ if ( event . options . mute ?? 0 > 2 ) {
890+ const sel = event . options . sel as string
891+ const cmd = ActionUtil . getMainSendMuteCommand ( sel , getNodeNumber ( event , 'src' ) , getNodeNumber ( event , 'dest' ) )
892+ ensureLoaded ( cmd )
893+ }
917894 } ,
918895 } ,
919896 [ CommonActions . SetMainSendFader ] : {
0 commit comments