bigbuffet-rw/app/soapbox/features/share/index.tsx
marcin mikołajczak c1618026a7 Fix share route
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-09-23 23:12:44 +02:00

30 lines
617 B
TypeScript

import React from 'react';
import { Redirect, useLocation } from 'react-router-dom';
import { openComposeWithText } from 'soapbox/actions/compose';
import { useAppDispatch } from 'soapbox/hooks';
const Share = () => {
const dispatch = useAppDispatch();
const { search } = useLocation();
const params = new URLSearchParams(search);
const text = [
params.get('title'),
params.get('text'),
params.get('url'),
]
.filter(v => v)
.join('\n\n');
if (text) {
dispatch(openComposeWithText('compose-modal', text));
}
return (
<Redirect to='/' />
);
};
export default Share;