Skip to content

Commit

Permalink
Merge pull request #16 from olzzon/develop
Browse files Browse the repository at this point in the history
Fix crash: If active index became higher than number of clips.
  • Loading branch information
olzzon authored Jan 23, 2019
2 parents 963ba6c + 4504d8b commit c944d41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class App extends PureComponent {
this.updatePlayingStatus = this.updatePlayingStatus.bind(this);
}

static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}

componentDidCatch(error, info) {
// You can also log the error to an error reporting service
logErrorToMyService(error, info);
}

componentWillMount() {
//Setup Keyboard shortcuts:
document.addEventListener("keydown", this._handleKeyDown.bind(this));
Expand Down
7 changes: 7 additions & 0 deletions src/reducers/dataReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export const dataReducer = ((state = defaultDataReducerState, action) => {
case 'SET_THUMB_LENGTH':
if (action.data.length < nextState[0].data.channel[action.data.tab].thumbList.length) {
nextState[0].data.channel[action.data.tab].thumbList.length = action.data.length;
// Check if active thumb is out of range of new thumblist.
if (nextState[0].data.channel[action.data.tab].thumbActiveIndex > (action.data.length - 1)) {
nextState[0].data.channel[action.data.tab].thumbActiveIndex = action.data.length - 1;
}
if (nextState[0].data.channel[action.data.tab].thumbActiveBgIndex > (action.data.length-1)) {
nextState[0].data.channel[action.data.tab].thumbActiveBgIndex = action.data.length - 1;
}
}
return nextState;
case 'SET_THUMB_LIST':
Expand Down

0 comments on commit c944d41

Please sign in to comment.