EmbeddedStatus: block navigation
This commit is contained in:
parent
54ff81afc6
commit
9fb9523a4e
|
@ -1,4 +1,5 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import { fetchStatus } from 'soapbox/actions/statuses';
|
import { fetchStatus } from 'soapbox/actions/statuses';
|
||||||
import MissingIndicator from 'soapbox/components/missing_indicator';
|
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. */
|
/** Status to be presented in an iframe for embeds on external websites. */
|
||||||
const EmbeddedStatus: React.FC<IEmbeddedStatus> = ({ params }) => {
|
const EmbeddedStatus: React.FC<IEmbeddedStatus> = ({ params }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const history = useHistory();
|
||||||
const status = useAppSelector(state => getStatus(state, { id: params.statusId }));
|
const status = useAppSelector(state => getStatus(state, { id: params.statusId }));
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
// Prevent navigation for UX and security.
|
||||||
|
// https://stackoverflow.com/a/71531211
|
||||||
|
history.block();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(fetchStatus(params.statusId))
|
dispatch(fetchStatus(params.statusId))
|
||||||
.then(() => setLoading(false))
|
.then(() => setLoading(false))
|
||||||
|
|
Loading…
Reference in New Issue