made it so going back closes file info and photo popup

This commit is contained in:
subnub
2025-02-19 02:22:04 -05:00
parent 74210f8fa6
commit de77ad412e
2 changed files with 23 additions and 2 deletions
+12 -1
View File
@@ -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 (
<div
className="w-screen dynamic-height bg-black bg-opacity-80 absolute top-0 left-0 right-0 bottom-0 z-50 flex justify-center items-center flex-col"
@@ -262,7 +262,6 @@ const PhotoViewerPopup: React.FC<PhotoViewerPopupProps> = memo((props) => {
};
useEffect(() => {
console.log("useeffect");
if (file.metadata.isVideo) {
getVideo();
}
@@ -272,6 +271,17 @@ const PhotoViewerPopup: React.FC<PhotoViewerPopupProps> = memo((props) => {
};
}, [file.metadata.isVideo, getVideo, cleanUpVideo]);
useEffect(() => {
const handleBack = () => {
closePhotoViewer();
};
window.addEventListener("popstate", handleBack);
return () => {
window.removeEventListener("popstate", handleBack);
};
}, []);
return (
<div
id="outer-wrapper"