2022-01-10 14:17:52 -08:00
|
|
|
import PropTypes from 'prop-types';
|
2021-10-01 10:36:58 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { Redirect } from 'react-router-dom';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-10-15 13:24:08 -07:00
|
|
|
import { openComposeWithText } from '../../actions/compose';
|
2021-10-01 10:36:58 -07:00
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
|
|
|
|
onShare: (text) => {
|
2021-10-15 13:24:08 -07:00
|
|
|
dispatch(openComposeWithText(text));
|
2021-10-01 10:36:58 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default @connect(null, mapDispatchToProps)
|
2021-10-15 13:30:24 -07:00
|
|
|
class Share extends React.Component {
|
2021-10-01 10:36:58 -07:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
onShare: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2021-10-15 13:24:08 -07:00
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
|
|
|
|
|
|
const text = [
|
|
|
|
params.get('title'),
|
|
|
|
params.get('text'),
|
|
|
|
params.get('url'),
|
|
|
|
]
|
|
|
|
.filter(v => v)
|
|
|
|
.join('\n\n');
|
|
|
|
|
|
|
|
if (text) {
|
|
|
|
this.props.onShare(text);
|
|
|
|
}
|
2021-10-01 10:36:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Redirect to='/' />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|