call: show video buttons if the cursor is over the app anywhere

pull/2165/head
audric 4 years ago
parent 5c8e4ef12b
commit b1221c6809

@ -3,7 +3,7 @@ import { animation, contextMenu, Item, Menu } from 'react-contexify';
import { InputItem } from '../../session/utils/calling/CallManager'; import { InputItem } from '../../session/utils/calling/CallManager';
import { setFullScreenCall } from '../../state/ducks/call'; import { setFullScreenCall } from '../../state/ducks/call';
import { CallManager, ToastUtils } from '../../session/utils'; import { CallManager, ToastUtils } from '../../session/utils';
import React from 'react'; import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { getHasOngoingCallWithPubkey } from '../../state/selectors/call'; import { getHasOngoingCallWithPubkey } from '../../state/selectors/call';
import { DropDownAndToggleButton } from '../icon/DropDownAndToggleButton'; import { DropDownAndToggleButton } from '../icon/DropDownAndToggleButton';
@ -317,7 +317,7 @@ const handleSpeakerToggle = async (
} }
}; };
const StyledCallWindowControls = styled.div` const StyledCallWindowControls = styled.div<{ makeVisible: boolean }>`
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
@ -335,10 +335,7 @@ const StyledCallWindowControls = styled.div`
display: flex; display: flex;
justify-content: center; justify-content: center;
opacity: 0; opacity: ${props => (props.makeVisible ? 1 : 0)};
&:hover {
opacity: 1;
}
`; `;
export const CallWindowControls = ({ export const CallWindowControls = ({
@ -360,8 +357,27 @@ export const CallWindowControls = ({
currentConnectedCameras: Array<InputItem>; currentConnectedCameras: Array<InputItem>;
isFullScreen: boolean; isFullScreen: boolean;
}) => { }) => {
const [makeVisible, setMakeVisible] = useState(true);
const setMakeVisibleTrue = () => {
setMakeVisible(true);
};
const setMakeVisibleFalse = () => {
setMakeVisible(false);
};
useEffect(() => {
setMakeVisibleTrue();
document.addEventListener('mouseenter', setMakeVisibleTrue);
document.addEventListener('mouseleave', setMakeVisibleFalse);
return () => {
document.removeEventListener('mouseenter', setMakeVisibleTrue);
document.removeEventListener('mouseleave', setMakeVisibleFalse);
};
}, [isFullScreen]);
return ( return (
<StyledCallWindowControls> <StyledCallWindowControls makeVisible={makeVisible}>
{!remoteStreamVideoIsMuted && <ShowInFullScreenButton isFullScreen={isFullScreen} />} {!remoteStreamVideoIsMuted && <ShowInFullScreenButton isFullScreen={isFullScreen} />}
<VideoInputButton <VideoInputButton

Loading…
Cancel
Save