From 3cf59ae2afeeb21d1c40be23cc43feed60593757 Mon Sep 17 00:00:00 2001 From: Cevo Date: Thu, 29 Oct 2015 15:31:25 +0100 Subject: [PATCH 1/3] added public note to piece --- js/components/ascribe_detail/piece_container.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 6b609161..462ac05b 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -267,6 +267,15 @@ let PieceContainer = React.createClass({ successMessage={getLangText('Private note saved')} url={ApiUrls.note_private_piece} currentUser={this.state.currentUser}/> + Date: Wed, 4 Nov 2015 13:56:43 +0100 Subject: [PATCH 2/3] Move store resets to componentDidMount() --- js/components/ascribe_detail/edition_container.js | 14 ++++++++------ js/components/ascribe_detail/piece_container.js | 14 ++++++++------ .../ascribe_detail/prize_piece_container.js | 14 +++++++++----- .../cyland/cyland_detail/cyland_piece_container.js | 5 ++--- .../ikonotv_detail/ikonotv_piece_container.js | 5 ++--- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/js/components/ascribe_detail/edition_container.js b/js/components/ascribe_detail/edition_container.js index 165913d4..6afb3123 100644 --- a/js/components/ascribe_detail/edition_container.js +++ b/js/components/ascribe_detail/edition_container.js @@ -17,6 +17,7 @@ import { setDocumentTitle } from '../../utils/dom_utils'; */ let EditionContainer = React.createClass({ propTypes: { + params: React.PropTypes.object, location: React.PropTypes.object }, @@ -38,7 +39,13 @@ let EditionContainer = React.createClass({ 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 @@ -51,11 +58,6 @@ 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); }, diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 462ac05b..3895b8b2 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -49,6 +49,7 @@ import { setDocumentTitle } from '../../utils/dom_utils'; */ let PieceContainer = React.createClass({ propTypes: { + params: React.PropTypes.object, location: React.PropTypes.object }, @@ -70,15 +71,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); diff --git a/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js b/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js index 07e84b0e..f2e22412 100644 --- a/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js +++ b/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js @@ -47,6 +47,10 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils'; * This is the component that implements resource/data specific functionality */ let PieceContainer = React.createClass({ + propTypes: { + params: React.PropTypes.object + }, + getInitialState() { return mergeOptions( PieceStore.getState(), @@ -58,6 +62,11 @@ let PieceContainer = React.createClass({ PieceStore.listen(this.onChange); PieceActions.fetchOne(this.props.params.pieceId); UserStore.listen(this.onChange); + + // 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 is done to update the container when the user clicks on the prev or next @@ -70,11 +79,6 @@ let PieceContainer = React.createClass({ }, 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); }, diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js index 79d63abf..1c61d573 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js @@ -52,9 +52,8 @@ let CylandPieceContainer = React.createClass({ UserStore.listen(this.onChange); PieceListStore.listen(this.onChange); - // 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 + // 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({}); diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js index 0c24de95..4e2f6a63 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js @@ -52,9 +52,8 @@ let IkonotvPieceContainer = React.createClass({ UserStore.listen(this.onChange); PieceListStore.listen(this.onChange); - // 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 + // 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({}); From 2711c4ddb9b719da4f11c949b4cfc8cbd43549ae Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Wed, 4 Nov 2015 13:57:15 +0100 Subject: [PATCH 3/3] Move onChange() to after componentWillUnmount() for ESLint --- .../ascribe_detail/edition_container.js | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/js/components/ascribe_detail/edition_container.js b/js/components/ascribe_detail/edition_container.js index 6afb3123..2c479d24 100644 --- a/js/components/ascribe_detail/edition_container.js +++ b/js/components/ascribe_detail/edition_container.js @@ -25,18 +25,6 @@ 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); @@ -62,6 +50,17 @@ let EditionContainer = React.createClass({ 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);