pl-fe: Fix share page

Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
mkljczk
2025-01-10 20:46:03 +01:00
parent 7f8185965a
commit b0240f5030

View File

@ -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 };