maybe fix links in modals

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-12-03 20:49:43 +01:00
parent 0d42fe1c96
commit c531c26078

View file

@ -105,8 +105,10 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
const handleModalOpen = () => { const handleModalOpen = () => {
modalHistoryKey.current = Date.now(); modalHistoryKey.current = Date.now();
unlistenHistory.current = history.listen((_, action) => { unlistenHistory.current = history.listen(({ state }, action) => {
if (action === 'POP') { if (!(state as any)?.soapboxModalKey) {
onClose();
} else if (action === 'POP') {
handleOnClose(); handleOnClose();
if (onCancel) onCancel(); if (onCancel) onCancel();
@ -118,11 +120,9 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
if (unlistenHistory.current) { if (unlistenHistory.current) {
unlistenHistory.current(); unlistenHistory.current();
} }
if (!['FAVOURITES', 'MENTIONS', 'REACTIONS', 'REBLOGS', 'MEDIA'].includes(type)) { const { state } = history.location;
const { state } = history.location; if (state && (state as any).soapboxModalKey === modalHistoryKey.current) {
if (state && (state as any).soapboxModalKey === modalHistoryKey.current) { history.goBack();
history.goBack();
}
} }
}; };
@ -174,7 +174,7 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
ensureHistoryBuffer(); ensureHistoryBuffer();
} }
}); }, [children]);
if (!visible) { if (!visible) {
return ( return (