EmbeddedStatus: block navigation

status-card
Alex Gleason 2022-08-21 13:32:51 -04:00
rodzic 54ff81afc6
commit 9fb9523a4e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -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))