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:
parent
d4bb23467e
commit
e19a20a60f
@ -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);
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user