fixed InfoPanel appearing in not avialable places

This commit is contained in:
mushka 2022-09-20 14:54:05 +03:00
parent fac0f14608
commit ca85150a6d

View File

@ -130,15 +130,17 @@ const StyledCrossIcon = styled(CrossIcon)`
StyledCrossIcon.defaultProps = { theme: Base };
const InfoPanel = ({ children, isVisible, setIsVisible, viewAs, isFiles }) => {
if (!isVisible) return null;
const InfoPanel = ({
children,
isVisible,
setIsVisible,
canDisplay,
viewAs,
}) => {
if (!isVisible || !canDisplay) return null;
const closeInfoPanel = () => setIsVisible(false);
useEffect(() => {
if (!isFiles) closeInfoPanel();
}, [isFiles]);
useEffect(() => {
const onMouseDown = (e) => {
if (e.target.id === "InfoPanelWrapper") closeInfoPanel();
@ -188,12 +190,13 @@ StyledInfoPanel.defaultProps = { theme: Base };
InfoPanel.defaultProps = { theme: Base };
export default inject(({ auth, filesStore }) => {
const { isVisible, setIsVisible } = auth.infoPanelStore;
const isFiles = true && filesStore;
const { isVisible, setIsVisible, getCanDisplay } = auth.infoPanelStore;
const canDisplay = getCanDisplay();
return {
isVisible,
setIsVisible,
isFiles,
canDisplay,
};
})(InfoPanel);