Skip to content

Commit

Permalink
Merge pull request #155 from CaptainFact/improvement/add-video-form
Browse files Browse the repository at this point in the history
Add video form: Accept url as URL param (/videos/add?url=xxx)
  • Loading branch information
Betree authored Jul 19, 2018
2 parents 1dd6f79 + 7796e88 commit a5efd7b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/components/Videos/AddVideoForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ const validate = ({ url }) => {

@withRouter
@connect((state, props) => ({
initialValues: {url: props.params.videoUrl},
initialValues: {url: props.params.videoUrl || props.location.query.url},
isSubmitting: state.Videos.isSubmitting,
isAuthenticated: isAuthenticated(state)
}), {postVideo, searchVideo})
@reduxForm({form: 'AddVideo', validate})
export class AddVideoForm extends React.PureComponent {
componentDidMount() {
if (this.props.params.videoUrl) {
this.props.searchVideo(decodeURI(this.props.params.videoUrl)).then(action => {
const videoUrl = this.props.params.videoUrl || this.props.location.query.url
if (videoUrl) {
this.props.searchVideo(decodeURI(videoUrl)).then(action => {
if (!action.error && action.payload !== null)
this.props.router.push(`/videos/${action.payload.id}`)
})
Expand Down

0 comments on commit a5efd7b

Please sign in to comment.