Skip to content

Commit

Permalink
fix: re-render grp fader
Browse files Browse the repository at this point in the history
chore: channel shouldcomponentupdate no assignment of variables
  • Loading branch information
olzzon committed Jun 12, 2019
1 parent 98e48a1 commit 738895c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 1 addition & 11 deletions src/components/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface IChannelInjectProps {
pflOn: boolean,
showChannel: boolean,
faderLevel: number,
outputLevel: number,
label: string,
snapOn: boolean[],
mixerProtocol: string,
Expand All @@ -40,21 +39,16 @@ class Channel extends React.Component<IChannelProps & IChannelInjectProps & Stor
}

public shouldComponentUpdate(nextProps: IChannelInjectProps) {
console.log("shouldComponentUpdate Next Props:", nextProps, "Current Props : ", this.props);
let updated = (nextProps.pgmOn != this.props.pgmOn ||
return (nextProps.pgmOn != this.props.pgmOn ||
nextProps.pstOn != this.props.pstOn ||
nextProps.pflOn != this.props.pflOn ||
nextProps.showChannel != this.props.showChannel ||
nextProps.faderLevel != this.props.faderLevel ||
nextProps.outputLevel != this.props.outputLevel ||
nextProps.label != this.props.label ||
nextProps.mixerProtocol != this.props.mixerProtocol ||
nextProps.showSnaps != this.props.showSnaps ||
nextProps.showPfl != this.props.showPfl)
//ToDo: handle snaps state re-rendering: nextProps.snapOn != this.props.snapOn ||

console.log("Channel :", this.props.channelIndex, " Update : ", updated)
return updated;
}

handlePgm() {
Expand Down Expand Up @@ -207,9 +201,6 @@ class Channel extends React.Component<IChannelProps & IChannelInjectProps & Stor
<div className="channel-name">
{this.props.label != "" ? this.props.label : ("CH " + (this.channelIndex + 1)) }
</div>
<div className="channel-gain-label">
GAIN: {Math.round(this.props.outputLevel * 100) / 100}
</div>
<div className="channel-snap-body">
{this.props.snapOn
.map((none: any, index: number) => {
Expand All @@ -229,7 +220,6 @@ const mapStateToProps = (state: any, props: any): IChannelInjectProps => {
pflOn: state.channels[0].channel[props.channelIndex].pflOn,
showChannel: state.channels[0].channel[props.channelIndex].showChannel,
faderLevel: state.channels[0].channel[props.channelIndex].faderLevel,
outputLevel: state.channels[0].channel[props.channelIndex].outputLevel,
label: state.channels[0].channel[props.channelIndex].label,
snapOn: state.channels[0].channel[props.channelIndex].snapOn.map((item: number) => {return item}),
mixerProtocol: state.settings[0].mixerProtocol,
Expand Down
12 changes: 12 additions & 0 deletions src/components/GrpFader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ class GrpFader extends PureComponent<IGrpFaderProps & IGrpFaderInjectProps & Sto

}

public shouldComponentUpdate(nextProps: IGrpFaderInjectProps) {
return (nextProps.pgmOn != this.props.pgmOn ||
nextProps.pstOn != this.props.pstOn ||
nextProps.showChannel != this.props.showChannel ||
nextProps.faderLevel != this.props.faderLevel ||
nextProps.label != this.props.label ||
nextProps.mixerProtocol != this.props.mixerProtocol ||
nextProps.showSnaps != this.props.showSnaps ||
nextProps.showPfl != this.props.showPfl)
//ToDo: handle snaps state re-rendering: nextProps.snapOn != this.props.snapOn ||
}

handlePgm() {
this.props.dispatch({
type:'TOGGLE_GRP_PGM',
Expand Down

0 comments on commit 738895c

Please sign in to comment.