Skip to content

Commit

Permalink
feat: add fader store set and remove assigned channel from fader
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Mar 22, 2021
1 parent fefa810 commit 73749ab
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/reducers/faderActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const SET_INPUT_SELECTOR = 'SET_INPUT_SELECTOR'
export const SET_CHANNEL_LABEL = 'SET_CHANNEL_LABEL'
export const SET_FADER_FX = 'SET_FADER_FX'
export const SET_FADER_MONITOR = 'SET_FADER_MONITOR'
export const SET_ASSIGNED_CHANNEL = 'SET_ASSIGNED_CHANNEL'
export const TOGGLE_PGM = 'TOGGLE_PGM'
export const SET_PGM = 'SET_PGM'
export const TOGGLE_VO = 'TOGGLE_VO'
Expand Down Expand Up @@ -272,6 +273,19 @@ export const storeSetAMix = (faderIndex: number, state: boolean) => {
}
}

export const storeSetAssignedChannel = (
faderIndex: number,
channelIndex: number,
assigned: boolean
) => {
return {
type: SET_ASSIGNED_CHANNEL,
faderIndex: faderIndex,
channelIndex: channelIndex,
assigned: assigned,
}
}

export const storeCapability = (
faderIndex: number,
capability: string,
Expand Down
27 changes: 27 additions & 0 deletions server/reducers/fadersReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
SET_AMIX,
SET_CAPABILITY,
TOGGLE_ALL_MANUAL,
SET_ASSIGNED_CHANNEL,
} from '../reducers/faderActions'

export interface IFaders {
Expand Down Expand Up @@ -298,6 +299,32 @@ export const faders = (
case SET_AMIX: //channel
nextState[0].fader[action.faderIndex].amixOn = action.state
return nextState
case SET_ASSIGNED_CHANNEL:
if (action.assigned) {
let assignedChannels =
nextState[0].fader[action.faderIndex].assignedChannels
assignedChannels.push(action.channelIndex)
assignedChannels.sort((a: number, b: number) => a)
nextState[0].fader[
action.faderIndex
].assignedChannels = assignedChannels
} else {
let assignedChannels =
nextState[0].fader[action.faderIndex].assignedChannels
if (
assignedChannels.find((channel: number, index: number) => {
return channel === action.channelIndex
})
) {
assignedChannels = assignedChannels.filter((channel) => {
return channel !== action.channelIndex
})
}
nextState[0].fader[
action.faderIndex
].assignedChannels = assignedChannels
}
return nextState
case SET_CAPABILITY:
nextState[0].fader[action.faderIndex].capabilities = {
...nextState[0].fader[action.faderIndex].capabilities,
Expand Down

0 comments on commit 73749ab

Please sign in to comment.