Skip to content

Commit

Permalink
feat: refactor - rename channel to faderIndex in all faderReducers an…
Browse files Browse the repository at this point in the history
…d faderActions

fix: chConnection renaming was not applied to all files
  • Loading branch information
olzzon committed Mar 16, 2021
1 parent fc22e4e commit e738ba4
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 180 deletions.
4 changes: 2 additions & 2 deletions client/components/ChanStrip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ const mapStateToProps = (state: any, props: any): IChanStripInjectProps => {
selectedProtocol: state.settings[0].mixers[0].mixerProtocol,
numberOfChannelsInType:
state.settings[0].mixers[0].numberOfChannelsInType,
channel: state.channels[0].chConnection[0].channel,
channel: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader,
auxSendIndex: -1,
offtubeMode: state.settings[0].offtubeMode,
Expand All @@ -531,7 +531,7 @@ const mapStateToProps = (state: any, props: any): IChanStripInjectProps => {
selectedProtocol: state.settings[0].mixers[0].mixerProtocol,
numberOfChannelsInType:
state.settings[0].mixers[0].numberOfChannelsInType,
channel: state.channels[0].chConnection[0].channel,
channel: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader,
auxSendIndex: state.faders[0].fader[props.faderIndex].monitor - 1,
offtubeMode: state.settings[0].offtubeMode,
Expand Down
4 changes: 2 additions & 2 deletions client/components/ChanStripFull.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ const mapStateToProps = (state: any, props: any): IChanStripFullInjectProps => {
selectedProtocol: state.settings[0].mixers[0].mixerProtocol,
numberOfChannelsInType:
state.settings[0].mixers[0].numberOfChannelsInType,
channel: state.channels[0].chConnection[0].channel,
channel: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader,
auxSendIndex: -1,
offtubeMode: state.settings[0].offtubeMode,
Expand All @@ -848,7 +848,7 @@ const mapStateToProps = (state: any, props: any): IChanStripFullInjectProps => {
selectedProtocol: state.settings[0].mixers[0].mixerProtocol,
numberOfChannelsInType:
state.settings[0].mixers[0].numberOfChannelsInType,
channel: state.channels[0].chConnection[0].channel,
channel: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader,
auxSendIndex: state.faders[0].fader[props.faderIndex].monitor - 1,
offtubeMode: state.settings[0].offtubeMode,
Expand Down
2 changes: 1 addition & 1 deletion client/components/ChannelMonitorOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const mapStateToProps = (
label: state.faders[0].fader[props.faderIndex].label,
selectedProtocol: state.settings[0].mixers[0].mixerProtocol,
numberOfChannelsInType: state.settings[0].mixers[0].numberOfChannelsInType,
channel: state.channels[0].chConnection[0].channel,
channel: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader,
settings: state.settings[0],
}
Expand Down
24 changes: 12 additions & 12 deletions client/components/ChannelRouteSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { Store } from 'redux'
import { connect } from 'react-redux'
import { storeShowOptions } from '../../server/reducers/settingsActions'
import { SOCKET_SET_ASSIGNED_FADER } from '../../server/constants/SOCKET_IO_DISPATCHERS'
import { IChannel, IchConnection } from '../../server/reducers/channelsReducer'
import { IChannel, IchMixerConnection } from '../../server/reducers/channelsReducer'
import { IFader } from '../../server/reducers/fadersReducer'

interface IChannelSettingsInjectProps {
label: string
chConnections: IchConnection[]
chMixerConnections: IchMixerConnection[]
fader: IFader[]
}

Expand Down Expand Up @@ -73,9 +73,9 @@ class ChannelRouteSettings extends React.PureComponent<

handleClearRouting() {
if (window.confirm('REMOVE ALL FADER ASSIGNMENTS????')) {
this.props.chConnections.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
chConnection.channel.forEach(
this.props.chMixerConnections.forEach(
(chMixerConnection: IchMixerConnection, mixerIndex: number) => {
chMixerConnection.channel.forEach(
(channel: any, index: number) => {
window.socketIoClient.emit(
SOCKET_SET_ASSIGNED_FADER,
Expand All @@ -95,7 +95,7 @@ class ChannelRouteSettings extends React.PureComponent<
handle11Routing() {
if (window.confirm('Reassign all Faders 1:1 to Channels????')) {
this.props.fader.forEach((fader: any, index: number) => {
if (this.props.chConnections[0].channel.length > index) {
if (this.props.chMixerConnections[0].channel.length > index) {
window.socketIoClient.emit(SOCKET_SET_ASSIGNED_FADER, {
mixerIndex: 0,
channel: index,
Expand All @@ -110,14 +110,14 @@ class ChannelRouteSettings extends React.PureComponent<
this.props.dispatch(storeShowOptions(this.faderIndex))
}

renderMixer(chConnection: IchConnection, mixerIndex: number) {
renderMixer(chMixerConnection: IchMixerConnection, mixerIndex: number) {
return (
<div>
<p className="channel-route-mixer-name">
{' '}
{'MIXER ' + (mixerIndex + 1)}
</p>
{chConnection.channel.map((channel: any, index: number) => {
{chMixerConnection.channel.map((channel: any, index: number) => {
return (
<div
key={index}
Expand Down Expand Up @@ -172,9 +172,9 @@ class ChannelRouteSettings extends React.PureComponent<
ROUTE 1.Mixer 1:1
</button>
<hr />
{this.props.chConnections.map(
(chConnection: IchConnection, mixerIndex: number) =>
this.renderMixer(chConnection, mixerIndex)
{this.props.chMixerConnections.map(
(chMixerConnection: IchMixerConnection, mixerIndex: number) =>
this.renderMixer(chMixerConnection, mixerIndex)
)}
</div>
)
Expand All @@ -187,7 +187,7 @@ const mapStateToProps = (
): IChannelSettingsInjectProps => {
return {
label: state.faders[0].fader[props.faderIndex].label,
chConnections: state.channels[0].chConnection,
chMixerConnections: state.channels[0].chMixerConnection,
fader: state.faders[0].fader,
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/components/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class Channels extends React.Component<IChannelsInjectProps & Store> {

const mapStateToProps = (state: any): IChannelsInjectProps => {
return {
channels: state.channels[0].chConnection[0].channel,
channels: state.channels[0].chMixerConnection[0].channel,
faders: state.faders[0].fader,
customPages: state.settings[0].customPages,
settings: state.settings[0],
Expand Down
4 changes: 2 additions & 2 deletions client/components/MiniChanStrip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const mapStateToProps = (state: any, props: any): IChanStripInjectProps => {
selectedProtocol: state.settings[0].mixers[0].mixerProtocol,
numberOfChannelsInType:
state.settings[0].mixers[0].numberOfChannelsInType,
channel: state.channels[0].chConnection[0].channel,
channel: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader,
auxSendIndex: -1,
offtubeMode: state.settings[0].offtubeMode,
Expand All @@ -119,7 +119,7 @@ const mapStateToProps = (state: any, props: any): IChanStripInjectProps => {
selectedProtocol: state.settings[0].mixers[0].mixerProtocol,
numberOfChannelsInType:
state.settings[0].mixers[0].numberOfChannelsInType,
channel: state.channels[0].chConnection[0].channel,
channel: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader,
auxSendIndex: state.faders[0].fader[props.faderIndex].monitor - 1,
offtubeMode: state.settings[0].offtubeMode,
Expand Down
4 changes: 2 additions & 2 deletions client/components/MiniChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ class MiniChannel extends React.Component<

const mapStateToProps = (state: any, props: any): IChannelInjectProps => {
return {
channels: state.channels[0].chConnection[0].channel,
channels: state.channels[0].chMixerConnection[0].channel,
fader: state.faders[0].fader[props.faderIndex],
settings: state.settings[0],
channelType: 0 /* TODO: state.channels[0].channel[props.channelIndex].channelType, */,
channelTypeIndex:
props.faderIndex /* TODO: state.channels[0].chConnection[0].channel[props.channelIndex].channelTypeIndex, */,
props.faderIndex /* TODO: state.channels[0].chMixerConnection[0].channel[props.channelIndex].channelTypeIndex, */,
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/components/MiniChannels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Channels extends React.Component<IChannelsInjectProps & Store> {

const mapStateToProps = (state: any): IChannelsInjectProps => {
return {
channels: state.channels[0].chConnection[0].channel,
channels: state.channels[0].chMixerConnection[0].channel,
faders: state.faders[0].fader,
settings: state.settings[0],
}
Expand Down
11 changes: 7 additions & 4 deletions client/utils/SocketClientHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
SOCKET_RETURN_PAGES_LIST,
} from '../../server/constants/SOCKET_IO_DISPATCHERS'
import {
IchConnection,
IchMixerConnection,
InumberOfChannels,
} from '../../server/reducers/channelsReducer'
import { VuType } from '../../server/utils/vuServer'
Expand Down Expand Up @@ -53,11 +53,14 @@ export const socketClientHandlers = () => {
// console.log('STATE RECEIVED :', payload)
if (window.mixerProtocol) {
let numberOfChannels: InumberOfChannels[] = []
payload.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
payload.channels[0].chMixerConnection.forEach(
(
chMixerConnection: IchMixerConnection,
mixerIndex: number
) => {
numberOfChannels.push({ numberOfTypeInCh: [] })
numberOfChannels[mixerIndex].numberOfTypeInCh = [
chConnection.channel.length,
chMixerConnection.channel.length,
]
}
)
Expand Down
18 changes: 10 additions & 8 deletions server/MainThreadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ export class MainThreadHandlers {
faderIndex: faderIndex,
state: state.faders[0].fader[faderIndex],
})
state.channels[0].chMixerConnection.forEach((chConnection) => {
chConnection.channel.forEach((channel: IChannel, index: number) => {
if (channel.assignedFader === faderIndex) {
socketServer.emit(SOCKET_SET_STORE_CHANNEL, {
channelIndex: index,
state: channel,
})
state.channels[0].chMixerConnection.forEach((chMixerConnection) => {
chMixerConnection.channel.forEach(
(channel: IChannel, index: number) => {
if (channel.assignedFader === faderIndex) {
socketServer.emit(SOCKET_SET_STORE_CHANNEL, {
channelIndex: index,
state: channel,
})
}
}
})
)
})
}

Expand Down
2 changes: 1 addition & 1 deletion server/__tests__/__mocks__/parsedEmptyStore.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"channels": [
{
"chConnection": [
"chMixerConnection": [
{
"channel": [
{
Expand Down
2 changes: 1 addition & 1 deletion server/__tests__/__mocks__/parsedFullStore.json
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@
],
"channels": [
{
"chConnection": [
"chMixerConnection": [
{
"channel": [
{
Expand Down
2 changes: 1 addition & 1 deletion server/__tests__/__mocks__/parsedSimpleStore.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"channels": [
{
"chConnection": [
"chMixerConnection": [
{
"channel": [
{
Expand Down
12 changes: 7 additions & 5 deletions server/__tests__/channelReducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Test redux channelReducer actions', () => {
it('should return the new output_level state on channels', () => {
let parsedFullStore = JSON.parse(parsedFullStoreJSON)
let nextState = JSON.parse(parsedFullStoreJSON)
nextState.channels[0].chConnection[0].channel[10].outputLevel = 0.5
nextState.channels[0].chMixerConnection[0].channel[10].outputLevel = 0.5
expect(
indexReducer(parsedFullStore, storeSetOutputLevel(0, 10, 0.5))
).toEqual(nextState)
Expand All @@ -33,7 +33,7 @@ describe('Test redux channelReducer actions', () => {
it('should return the new assignedFader state on channels', () => {
let parsedFullStore = JSON.parse(parsedFullStoreJSON)
let nextState = JSON.parse(parsedFullStoreJSON)
nextState.channels[0].chConnection[0].channel[10].assignedFader = 2
nextState.channels[0].chMixerConnection[0].channel[10].assignedFader = 2
expect(
indexReducer(parsedFullStore, storeSetAssignedFader(0, 10, 2))
).toEqual(nextState)
Expand All @@ -46,7 +46,7 @@ describe('Test redux channelReducer actions', () => {
it('should return the new FADE_ACTIVE state on channels', () => {
let parsedFullStore = JSON.parse(parsedFullStoreJSON)
let nextState = JSON.parse(parsedFullStoreJSON)
nextState.channels[0].chConnection[0].channel[10].fadeActive = true
nextState.channels[0].chMixerConnection[0].channel[10].fadeActive = true
expect(
indexReducer(parsedFullStore, storeFadeActive(0, 10, true))
).toEqual(nextState)
Expand All @@ -71,13 +71,15 @@ describe('Test redux channelReducer actions', () => {
fadeActive: false,
outputLevel: 0.75,
})
nextState.channels[0].chConnection[0].channel[i].outputLevel = 0.75
nextState.channels[0].chMixerConnection[0].channel[
i
].outputLevel = 0.75
}
expect(
indexReducer(
parsedFullStore,
storeSetCompleteChState(
{ chConnection: [{ channel: channels }] },
{ chMixerConnection: [{ channel: channels }] },
numberOfChannels
)
)
Expand Down
37 changes: 20 additions & 17 deletions server/reducers/channelsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,32 @@ export const channels = (
): Array<IChannels> => {
let nextState = [
{
chConnection: [...state[0].chMixerConnection],
chMixerConnection: [...state[0].chMixerConnection],
},
]

switch (action.type) {
case SET_OUTPUT_LEVEL:
nextState[0].chConnection[action.mixerIndex].channel[
nextState[0].chMixerConnection[action.mixerIndex].channel[
action.channel
].outputLevel = parseFloat(action.level)
return nextState
case SET_COMPLETE_CH_STATE:
nextState = defaultChannelsReducerState(action.numberOfTypeChannels)

nextState[0].chConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
nextState[0].chMixerConnection.forEach(
(chMixerConnection: IchMixerConnection, mixerIndex: number) => {
chMixerConnection.channel.forEach(
(channel: any, index: number) => {
if (
index <
action.allState.chConnection[mixerIndex]
action.allState.chMixerConnection[mixerIndex]
?.channel.length
) {
nextState[0].chConnection[mixerIndex].channel[
index
] =
action.allState.chConnection[
nextState[0].chMixerConnection[
mixerIndex
].channel[index] =
action.allState.chMixerConnection[
mixerIndex
].channel[index]
}
Expand All @@ -112,31 +112,34 @@ export const channels = (

return nextState
case SET_SINGLE_CH_STATE:
nextState[0].chConnection[0].channel[action.channelIndex] =
nextState[0].chMixerConnection[0].channel[action.channelIndex] =
action.state
return nextState
case FADE_ACTIVE:
nextState[0].chConnection[action.mixerIndex].channel[
nextState[0].chMixerConnection[action.mixerIndex].channel[
action.channel
].fadeActive = !!action.active
return nextState
case SET_ASSIGNED_FADER:
nextState[0].chConnection[action.mixerIndex].channel[
nextState[0].chMixerConnection[action.mixerIndex].channel[
action.channel
].assignedFader = action.faderNumber
return nextState
case SET_AUX_LEVEL:
nextState[0].chConnection[action.mixerIndex].channel[
nextState[0].chMixerConnection[action.mixerIndex].channel[
action.channel
].auxLevel[action.auxIndex] = parseFloat(action.level)
return nextState
case SET_PRIVATE:
if (!nextState[0].chConnection[0].channel[action.channel].private) {
nextState[0].chConnection[0].channel[
if (
!nextState[0].chMixerConnection[0].channel[action.channel]
.private
) {
nextState[0].chMixerConnection[0].channel[
action.channel
].private = {}
}
nextState[0].chConnection[0].channel[action.channel].private![
nextState[0].chMixerConnection[0].channel[action.channel].private![
action.tag
] = action.value
return nextState
Expand Down
Loading

0 comments on commit e738ba4

Please sign in to comment.