()
| 8 | interface ScreenshareButtonProps {} |
| 9 | |
| 10 | export const ScreenshareButton: FC<ScreenshareButtonProps> = () => { |
| 11 | const { |
| 12 | userMedia: { startScreenShare, endScreenShare, screenShareEnabled }, |
| 13 | } = useRoomContext() |
| 14 | |
| 15 | const [canShareScreen, setCanShareScreen] = useState(true) |
| 16 | |
| 17 | // setting this in a useEffect because we need to do this feature |
| 18 | // detection to remove it for iOS, but the feature detection also |
| 19 | // doesn't work on the server, so it causes a mismatch between |
| 20 | // the server/client that React doesn't like |
| 21 | useEffect(() => { |
| 22 | setCanShareScreen( |
| 23 | typeof navigator.mediaDevices !== 'undefined' && |
| 24 | navigator.mediaDevices.getDisplayMedia !== undefined |
| 25 | ) |
| 26 | }, []) |
| 27 | |
| 28 | if (!canShareScreen) return null |
| 29 | |
| 30 | return ( |
| 31 | <Button |
| 32 | displayType={screenShareEnabled ? 'danger' : 'secondary'} |
| 33 | onClick={screenShareEnabled ? endScreenShare : startScreenShare} |
| 34 | > |
| 35 | <VisuallyHidden>Share screen</VisuallyHidden> |
| 36 | <Icon type="screenshare" /> |
| 37 | </Button> |
| 38 | ) |
| 39 | } |
nothing calls this directly
no test coverage detected