diff --git a/js/components/ascribe_detail/edition_container.js b/js/components/ascribe_detail/edition_container.js index 3bab238d..cb828237 100644 --- a/js/components/ascribe_detail/edition_container.js +++ b/js/components/ascribe_detail/edition_container.js @@ -27,21 +27,15 @@ let EditionContainer = React.createClass({ return EditionStore.getState(); }, - onChange(state) { - this.setState(state); - if (!state.edition.digital_work) { - return; - } - let isEncoding = state.edition.digital_work.isEncoding; - if (state.edition.digital_work.mime === 'video' && typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) { - let timerId = window.setInterval(() => EditionActions.fetchOne(this.props.params.editionId), 10000); - this.setState({timerId: timerId}); - } - }, - componentDidMount() { EditionStore.listen(this.onChange); - EditionActions.fetchOne(this.props.params.editionId); + + // Every time we enter the edition detail page, just reset the edition + // store as it will otherwise display wrong/old data once the user loads + // the edition detail a second time + EditionActions.updateEdition({}); + + this.loadEdition(); }, // This is done to update the container when the user clicks on the prev or next @@ -54,15 +48,21 @@ let EditionContainer = React.createClass({ }, componentWillUnmount() { - // Every time we're leaving the edition detail page, - // just reset the edition that is saved in the edition store - // as it will otherwise display wrong/old data once the user loads - // the edition detail a second time - EditionActions.updateEdition({}); window.clearInterval(this.state.timerId); EditionStore.unlisten(this.onChange); }, + onChange(state) { + this.setState(state); + if (!state.edition.digital_work) { + return; + } + let isEncoding = state.edition.digital_work.isEncoding; + if (state.edition.digital_work.mime === 'video' && typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) { + let timerId = window.setInterval(() => EditionActions.fetchOne(this.props.params.editionId), 10000); + this.setState({timerId: timerId}); + } + }, loadEdition() { EditionActions.fetchOne(this.props.params.editionId); diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 34e5144c..8b9ef679 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -49,8 +49,8 @@ import { setDocumentTitle } from '../../utils/dom_utils'; */ let PieceContainer = React.createClass({ propTypes: { - params: React.PropTypes.object, furtherDetailsType: React.PropTypes.func, + params: React.PropTypes.object, location: React.PropTypes.object }, @@ -78,15 +78,16 @@ let PieceContainer = React.createClass({ PieceListStore.listen(this.onChange); UserActions.fetchCurrentUser(); PieceStore.listen(this.onChange); - PieceActions.fetchOne(this.props.params.pieceId); + + // Every time we enter the piece detail page, just reset the piece + // store as it will otherwise display wrong/old data once the user loads + // the piece detail a second time + PieceActions.updatePiece({}); + + this.loadPiece(); }, componentWillUnmount() { - // Every time we're leaving the piece detail page, - // just reset the piece that is saved in the piece store - // as it will otherwise display wrong/old data once the user loads - // the piece detail a second time - PieceActions.updatePiece({}); PieceStore.unlisten(this.onChange); UserStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange); @@ -276,6 +277,15 @@ let PieceContainer = React.createClass({ successMessage={getLangText('Private note saved')} url={ApiUrls.note_private_piece} currentUser={this.state.currentUser}/> +