kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Share: support title and url params
rodzic
2284a4bae5
commit
966f0e84e4
|
@ -615,3 +615,11 @@ export function changePollSettings(expiresIn, isMultiple) {
|
||||||
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 { Redirect } from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { changeCompose } from '../../actions/compose';
|
import { openComposeWithText } from '../../actions/compose';
|
||||||
import { openModal } from '../../actions/modal';
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
||||||
onShare: (text) => {
|
onShare: (text) => {
|
||||||
dispatch(openModal('COMPOSE'));
|
dispatch(openComposeWithText(text));
|
||||||
dispatch(changeCompose(text));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -25,8 +23,19 @@ class Share extends ImmutablePureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const text = new URLSearchParams(window.location.search).get('text');
|
const params = new URLSearchParams(window.location.search);
|
||||||
if (text) this.props.onShare(text);
|
|
||||||
|
const text = [
|
||||||
|
params.get('title'),
|
||||||
|
params.get('text'),
|
||||||
|
params.get('url'),
|
||||||
|
]
|
||||||
|
.filter(v => v)
|
||||||
|
.join('\n\n');
|
||||||
|
|
||||||
|
if (text) {
|
||||||
|
this.props.onShare(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Ładowanie…
Reference in New Issue