1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Remove unnecessary duplication of updating encoding status in Edition

Also reduces the time between each update to 5s since 10s feels way too
long.
This commit is contained in:
Brett Sun 2016-01-12 17:55:37 +01:00
commit cc9fa2378f
2 changed files with 9 additions and 16 deletions

View File

@ -73,14 +73,6 @@ let EditionContainer = React.createClass({
onChange(state) { onChange(state) {
this.setState(state); this.setState(state);
if (state && state.edition && state.edition.digital_work) {
const isEncoding = state.edition.digital_work.isEncoding;
if (state.edition.digital_work.mime === 'video' && typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) {
const timerId = window.setInterval(() => EditionActions.fetchOne(this.props.params.editionId), 10000);
this.setState({ timerId: timerId });
}
}
}, },
render() { render() {

View File

@ -20,6 +20,7 @@ const EMBED_IFRAME_HEIGHT = {
video: 315, video: 315,
audio: 62 audio: 62
}; };
const ENCODE_UPDATE_TIME = 5000;
let MediaContainer = React.createClass({ let MediaContainer = React.createClass({
propTypes: { propTypes: {
@ -36,15 +37,15 @@ let MediaContainer = React.createClass({
}, },
componentDidMount() { componentDidMount() {
const { content, refreshObject } = this.props; const { content: { digital_work: digitalWork }, refreshObject } = this.props;
if (!content.digital_work) {
return;
}
const isEncoding = content.digital_work.isEncoding; if (digitalWork) {
if (content.digital_work.mime === 'video' && typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) { const isEncoding = digitalWork.isEncoding;
const timerId = window.setInterval(refreshObject, 10000);
this.setState({timerId: timerId}); if (digitalWork.mime === 'video' && typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) {
const timerId = window.setInterval(refreshObject, ENCODE_UPDATE_TIME);
this.setState({ timerId: timerId });
}
} }
}, },