import { FC, useCallback, useState } from 'react'; import { RoomWidgetCameraEvent } from '../../../../events/room-widgets/camera/RoomWidgetCameraEvent'; import { DraggableWindow } from '../../../../hooks/draggable-window/DraggableWindow'; import { useUiEvent } from '../../../../hooks/events/ui/ui-event'; import { CameraWidgetViewProps } from './CameraWidgetView.types'; export const CameraWidgetView: FC = props => { const [ isVisible, setIsVisible ] = useState(false); const onRoomWidgetCameraEvent = useCallback((event: RoomWidgetCameraEvent) => { switch(event.type) { case RoomWidgetCameraEvent.SHOW_CAMERA: setIsVisible(true); return; case RoomWidgetCameraEvent.HIDE_CAMERA: setIsVisible(false); return; case RoomWidgetCameraEvent.TOGGLE_CAMERA: setIsVisible(value => !value); return; } }, []); useUiEvent(RoomWidgetCameraEvent.SHOW_CAMERA, onRoomWidgetCameraEvent); useUiEvent(RoomWidgetCameraEvent.HIDE_CAMERA, onRoomWidgetCameraEvent); useUiEvent(RoomWidgetCameraEvent.TOGGLE_CAMERA, onRoomWidgetCameraEvent); const processAction = useCallback((type: string, value: string = null) => { switch(type) { case 'close': setIsVisible(false); return; } }, []); if(!isVisible) return null; return (
processAction('close') }>
); }