Skip to content

Commit

Permalink
fix: ui crash when an invalid channel number was used by automation
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Feb 2, 2021
1 parent 4be630b commit 66ee580
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
8 changes: 5 additions & 3 deletions client/utils/SocketClientHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ export const socketClientHandlers = () => {
)
})
.on(SOCKET_SET_STORE_FADER, (payload: any) => {
window.storeRedux.dispatch(
storeSetSingleFaderState(payload.faderIndex, payload.state)
)
if ('faderIndex' in payload && 'state' in payload) {
window.storeRedux.dispatch(
storeSetSingleFaderState(payload.faderIndex, payload.state)
)
}
})
.on(SOCKET_SET_STORE_CHANNEL, (payload: any) => {
window.storeRedux.dispatch(
Expand Down
5 changes: 4 additions & 1 deletion server/reducers/fadersReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ export const faders = (
fader: [...state[0].fader],
},
]
if (action.channel > nextState[0].fader.length) {
if (
action.channel &&
(action.channel < 0 || action.channel >= nextState[0].fader.length)
) {
return nextState
}

Expand Down
20 changes: 16 additions & 4 deletions server/utils/AutomationConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export class AutomationConnection {
)
) {
let ch = message.address.split('/')[2]
if (!state.faders[0].fader[ch - 1].ignoreAutomation) {
if (
state.faders[0].fader[ch - 1] &&
!state.faders[0].fader[ch - 1].ignoreAutomation
) {
if (message.args[0] === 1) {
mixerGenericConnection.checkForAutoResetThreshold(
ch - 1
Expand Down Expand Up @@ -104,7 +107,10 @@ export class AutomationConnection {
)
) {
let ch = message.address.split('/')[2]
if (!state.faders[0].fader[ch - 1].ignoreAutomation) {
if (
state.faders[0].fader[ch - 1] &&
!state.faders[0].fader[ch - 1].ignoreAutomation
) {
if (message.args[0] === 1) {
store.dispatch(storeSetPst(ch - 1, true))
} else if (message.args[0] === 2) {
Expand All @@ -122,7 +128,10 @@ export class AutomationConnection {
)
) {
let ch = message.address.split('/')[2]
if (!state.faders[0].fader[ch - 1].ignoreAutomation) {
if (
state.faders[0].fader[ch - 1] &&
!state.faders[0].fader[ch - 1].ignoreAutomation
) {
store.dispatch(
storeSetMute(ch - 1, message.args[0] === 1)
)
Expand All @@ -137,7 +146,10 @@ export class AutomationConnection {
)
) {
let ch = message.address.split('/')[2]
if (!state.faders[0].fader[ch - 1].ignoreAutomation) {
if (
state.faders[0].fader[ch - 1] &&
!state.faders[0].fader[ch - 1].ignoreAutomation
) {
store.dispatch(
storeFaderLevel(ch - 1, message.args[0])
)
Expand Down

0 comments on commit 66ee580

Please sign in to comment.