1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00

add polling to piece

This commit is contained in:
vrde 2015-07-15 17:13:45 +02:00
parent d4bb23467e
commit e19a20a60f

View File

@ -21,6 +21,11 @@ let PieceContainer = React.createClass({
onChange(state) {
this.setState(state);
let isEncoding = state.piece.digital_work ? state.piece.digital_work.isEncoding : null;
if (typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) {
let timerId = window.setInterval(() => PieceActions.fetchOne(this.props.params.pieceId), 10000);
this.setState({timerId: timerId});
}
},
componentDidMount() {
@ -34,7 +39,7 @@ let PieceContainer = React.createClass({
// as it will otherwise display wrong/old data once the user loads
// the piece detail a second time
PieceActions.updatePiece({});
window.clearInterval(this.state.timerId);
PieceStore.unlisten(this.onChange);
},