Implement /share route

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
merge-requests/783/head
marcin mikołajczak 3 years ago
parent 796117ecca
commit 6235ca5ab2

@ -0,0 +1,38 @@
import React from 'react';
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';
const mapDispatchToProps = dispatch => ({
onShare: (text) => {
dispatch(openModal('COMPOSE'));
dispatch(changeCompose(text));
},
});
export default @connect(null, mapDispatchToProps)
class Share extends ImmutablePureComponent {
static propTypes = {
onShare: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
const text = new URLSearchParams(window.location.search).get('text');
if (text) this.props.onShare(text);
}
render() {
return (
<Redirect to='/' />
);
}
}

@ -107,6 +107,7 @@ import {
ModalContainer,
ProfileHoverCard,
RegisterInvite,
Share,
} from './util/async-components';
// Dummy import, to make sure that <Status /> ends up in the application bundle.
@ -299,6 +300,8 @@ class SwitchingColumnsArea extends React.PureComponent {
<WrappedRoute path='/donate/crypto' publicRoute page={DefaultPage} component={CryptoDonate} content={children} />
<WrappedRoute path='/federation_restrictions' publicRoute page={DefaultPage} component={FederationRestrictions} content={children} />
<WrappedRoute path='/share' page={DefaultPage} component={Share} content={children} exact />
<WrappedRoute page={EmptyPage} component={GenericNotFound} content={children} />
</Switch>
);

@ -405,3 +405,7 @@ export function FollowRecommendations() {
export function RegisterInvite() {
return import(/* webpackChunkName: "features/register_invite" */'../../register_invite');
}
export function Share() {
return import(/* webpackChunkName: "features/share" */'../../share');
}

@ -84,7 +84,7 @@ class WrappedRoute extends React.Component {
const { component: Component, content, publicRoute, me, ...rest } = this.props;
if (!publicRoute && me === false) {
const actualUrl = encodeURIComponent(this.props.computedMatch.url); // eslint-disable-line react/prop-types
const actualUrl = encodeURIComponent(`${this.props.computedMatch.url}${this.props.location.search}`); // eslint-disable-line react/prop-types
return <Redirect to={`/auth/sign_in?redirect_uri=${actualUrl}`} />;
// return <Route path={this.props.path} component={() => {
// window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`;

Loading…
Cancel
Save