Skip to content

Commit

Permalink
pl-fe: Fix share page
Browse files Browse the repository at this point in the history
Signed-off-by: mkljczk <[email protected]>
  • Loading branch information
mkljczk committed Jan 10, 2025
1 parent 7f81859 commit b0240f5
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions packages/pl-fe/src/features/share/index.tsx
Original file line number Diff line number Diff line change
@@ -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');

if (text) {
dispatch(openComposeWithText('compose-modal', text));
}

return (
<Redirect to='/' />
);

useEffect(() => {
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));
}

history.replace('/');
});

return null;
};

export { Share as default };

0 comments on commit b0240f5

Please sign in to comment.