EmbeddedStatus: block navigation

environments/review-embedded-s-jkh70t/deployments/805
Alex Gleason 2 years ago
parent 54ff81afc6
commit 9fb9523a4e
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { fetchStatus } from 'soapbox/actions/statuses';
import MissingIndicator from 'soapbox/components/missing_indicator';
@ -18,10 +19,15 @@ const getStatus = makeGetStatus();
/** Status to be presented in an iframe for embeds on external websites. */
const EmbeddedStatus: React.FC<IEmbeddedStatus> = ({ params }) => {
const dispatch = useAppDispatch();
const history = useHistory();
const status = useAppSelector(state => getStatus(state, { id: params.statusId }));
const [loading, setLoading] = useState(true);
// Prevent navigation for UX and security.
// https://stackoverflow.com/a/71531211
history.block();
useEffect(() => {
dispatch(fetchStatus(params.statusId))
.then(() => setLoading(false))

Loading…
Cancel
Save