From de77ad412e8e06f876e4c68befd76afcb69602ae Mon Sep 17 00:00:00 2001 From: subnub Date: Wed, 19 Feb 2025 02:22:04 -0500 Subject: [PATCH] made it so going back closes file info and photo popup --- src/components/FileInfoPopup/FileInfoPopup.tsx | 13 ++++++++++++- .../PhotoViewerPopup/PhotoViewerPopup.tsx | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/FileInfoPopup/FileInfoPopup.tsx b/src/components/FileInfoPopup/FileInfoPopup.tsx index 26d435d..d2b8c6d 100644 --- a/src/components/FileInfoPopup/FileInfoPopup.tsx +++ b/src/components/FileInfoPopup/FileInfoPopup.tsx @@ -1,4 +1,4 @@ -import { useMemo } from "react"; +import { useEffect, useMemo } from "react"; import { useAppDispatch, useAppSelector } from "../../hooks/store"; import { downloadFileAPI } from "../../api/filesAPI"; import CloseIcon from "../../icons/CloseIcon"; @@ -52,6 +52,17 @@ const FileInfoPopup = () => { dispatch(resetPopupSelect()); }; + useEffect(() => { + const handleBack = () => { + dispatch(resetPopupSelect()); + }; + window.addEventListener("popstate", handleBack); + + return () => { + window.removeEventListener("popstate", handleBack); + }; + }, []); + return (
= memo((props) => { }; useEffect(() => { - console.log("useeffect"); if (file.metadata.isVideo) { getVideo(); } @@ -272,6 +271,17 @@ const PhotoViewerPopup: React.FC = memo((props) => { }; }, [file.metadata.isVideo, getVideo, cleanUpVideo]); + useEffect(() => { + const handleBack = () => { + closePhotoViewer(); + }; + window.addEventListener("popstate", handleBack); + + return () => { + window.removeEventListener("popstate", handleBack); + }; + }, []); + return (