made it so going back closes file info and photo popup
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user