2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-12-18 04:46:37 +00:00
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
|
import queryString from 'query-string'
|
|
|
|
import { clearCompose, changeCompose } from '../../actions/compose'
|
2020-05-15 03:31:24 +01:00
|
|
|
import ComposeFormContainer from './containers/compose_form_container'
|
2019-08-09 17:06:27 +01:00
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class Compose extends React.PureComponent {
|
2020-08-11 04:01:09 +01:00
|
|
|
|
2020-12-18 04:46:37 +00:00
|
|
|
componentDidMount() {
|
|
|
|
const search = this.context.router.route.location.search
|
|
|
|
try {
|
|
|
|
const qp = queryString.parse(search)
|
|
|
|
const url = `${qp.url || ''}`
|
|
|
|
const text = `${qp.text || ''}`
|
|
|
|
|
|
|
|
if (url.length > 0 || text.length > 0) {
|
|
|
|
let value = ""
|
|
|
|
if (text.length > 0) value += `${text} `
|
|
|
|
if (url.length > 0) value += url
|
|
|
|
this.props.dispatch(changeCompose(value))
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 04:01:09 +01:00
|
|
|
componentWillUnmount() {
|
2020-12-09 04:15:33 +00:00
|
|
|
this.props.dispatch(clearCompose())
|
2020-08-11 04:01:09 +01:00
|
|
|
}
|
2019-08-09 17:06:27 +01:00
|
|
|
|
|
|
|
render () {
|
2020-12-16 00:31:30 +00:00
|
|
|
return <ComposeFormContainer formLocation='standalone' />
|
2019-08-09 17:06:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-17 23:06:22 +01:00
|
|
|
|
2020-12-18 04:46:37 +00:00
|
|
|
Compose.contextTypes = {
|
|
|
|
router: PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withRouter(connect()(Compose))
|