Share: support title and url params
This commit is contained in:
parent
2284a4bae5
commit
966f0e84e4
|
@ -615,3 +615,11 @@ export function changePollSettings(expiresIn, isMultiple) {
|
|||
isMultiple,
|
||||
};
|
||||
}
|
||||
|
||||
export function openComposeWithText(text = '') {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(resetCompose());
|
||||
dispatch(openModal('COMPOSE'));
|
||||
dispatch(changeCompose(text));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,14 +3,12 @@ import { connect } from 'react-redux';
|
|||
import { Redirect } from 'react-router-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { changeCompose } from '../../actions/compose';
|
||||
import { openModal } from '../../actions/modal';
|
||||
import { openComposeWithText } from '../../actions/compose';
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
||||
onShare: (text) => {
|
||||
dispatch(openModal('COMPOSE'));
|
||||
dispatch(changeCompose(text));
|
||||
dispatch(openComposeWithText(text));
|
||||
},
|
||||
|
||||
});
|
||||
|
@ -25,8 +23,19 @@ class Share extends ImmutablePureComponent {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
const text = new URLSearchParams(window.location.search).get('text');
|
||||
if (text) this.props.onShare(text);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Reference in New Issue