Fixed loading of content for document page change

This commit is contained in:
Jori Lallo
2017-06-25 15:37:04 -07:00
parent b7dd74fb6c
commit e02768606a

View File

@ -44,18 +44,27 @@ type Props = {
}
componentDidMount() {
if (this.props.newDocument) {
this.store.collectionId = this.props.match.params.id;
this.loadDocument(this.props);
}
componentWillReceiveProps(nextProps) {
if (nextProps.match.params.id !== this.props.match.params.id)
this.loadDocument(nextProps);
}
loadDocument(props) {
if (props.newDocument) {
this.store.collectionId = props.match.params.id;
this.store.newDocument = true;
} else if (this.props.match.params.edit) {
this.store.documentId = this.props.match.params.id;
} else if (props.match.params.edit) {
this.store.documentId = props.match.params.id;
this.store.fetchDocument();
} else if (this.props.newChildDocument) {
this.store.documentId = this.props.match.params.id;
} else if (props.newChildDocument) {
this.store.documentId = props.match.params.id;
this.store.newChildDocument = true;
this.store.fetchDocument();
} else {
this.store.documentId = this.props.match.params.id;
this.store.documentId = props.match.params.id;
this.store.newDocument = false;
this.store.fetchDocument();
}