diff --git a/src/ContactEdit.tsx b/src/ContactEdit.tsx index 3f14862..3a4ecc2 100644 --- a/src/ContactEdit.tsx +++ b/src/ContactEdit.tsx @@ -150,7 +150,9 @@ class ContactEdit extends React.Component { this.state.uid = uuid.v4(); } - if (props.collections[0]) { + if (props.initialCollection) { + this.state.journalUid = props.initialCollection; + } else if (props.collections[0]) { this.state.journalUid = props.collections[0].uid; } this.onSubmit = this.onSubmit.bind(this); @@ -162,9 +164,12 @@ class ContactEdit extends React.Component { } componentWillReceiveProps(nextProps: any) { - if (this.props.collections !== nextProps.collections) { - if (nextProps.collections[0]) { - this.setState({journalUid: nextProps.collections[0].uid}); + if ((this.props.collections !== nextProps.collections) || + (this.props.initialCollection !== nextProps.initialCollection)) { + if (nextProps.initialCollection) { + this.state.journalUid = nextProps.initialCollection; + } else if (nextProps.collections[0]) { + this.state.journalUid = nextProps.collections[0].uid; } } } diff --git a/src/EventEdit.tsx b/src/EventEdit.tsx index c01a907..e066e18 100644 --- a/src/EventEdit.tsx +++ b/src/EventEdit.tsx @@ -59,9 +59,12 @@ class EventEdit extends React.Component { this.state.uid = uuid.v4(); } - if (this.props.collections[0]) { + if (props.initialCollection) { + this.state.journalUid = props.initialCollection; + } else if (props.collections[0]) { this.state.journalUid = props.collections[0].uid; } + this.onSubmit = this.onSubmit.bind(this); this.handleChange = this.handleChange.bind(this); this.handleInputChange = this.handleInputChange.bind(this); @@ -69,9 +72,12 @@ class EventEdit extends React.Component { } componentWillReceiveProps(nextProps: any) { - if (this.props.collections !== nextProps.collections) { - if (nextProps.collections[0]) { - this.setState({journalUid: nextProps.collections[0].uid}); + if ((this.props.collections !== nextProps.collections) || + (this.props.initialCollection !== nextProps.initialCollection)) { + if (nextProps.initialCollection) { + this.state.journalUid = nextProps.initialCollection; + } else if (nextProps.collections[0]) { + this.state.journalUid = nextProps.collections[0].uid; } } } diff --git a/src/Pim.tsx b/src/Pim.tsx index 0dcf15a..bae59af 100644 --- a/src/Pim.tsx +++ b/src/Pim.tsx @@ -156,6 +156,7 @@ class Pim extends React.Component { render={({match}) => ( (