@ -1,30 +1,34 @@
|
||||
import React from 'react';
|
||||
import { Redirect, useLocation } from 'react-router-dom';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
|
||||
import { openComposeWithText } from 'pl-fe/actions/compose';
|
||||
import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
|
||||
|
||||
const Share = () => {
|
||||
const Share: React.FC = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const history = useHistory();
|
||||
|
||||
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');
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams(search);
|
||||
|
||||
if (text) {
|
||||
dispatch(openComposeWithText('compose-modal', text));
|
||||
}
|
||||
const text = [
|
||||
params.get('title'),
|
||||
params.get('text'),
|
||||
params.get('url'),
|
||||
]
|
||||
.filter(v => v)
|
||||
.join('\n\n');
|
||||
|
||||
return (
|
||||
<Redirect to='/' />
|
||||
);
|
||||
if (text) {
|
||||
dispatch(openComposeWithText('compose-modal', text));
|
||||
}
|
||||
|
||||
history.replace('/');
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export { Share as default };
|
||||
|
||||
Reference in New Issue
Block a user