commentary on haircheck
This commit is contained in:
parent
8985d00a90
commit
60b09b51f2
|
|
@ -21,6 +21,13 @@ import IconSettings from '@dailyjs/shared/icons/settings-sm.svg';
|
||||||
|
|
||||||
import { useDeepCompareMemo } from 'use-deep-compare';
|
import { useDeepCompareMemo } from 'use-deep-compare';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hair check
|
||||||
|
* ---
|
||||||
|
* - Setup local media devices to see how you look / sound
|
||||||
|
* - Toggle mute state of camera and mic
|
||||||
|
* - Set user name and join call / request access
|
||||||
|
*/
|
||||||
export const HairCheck = () => {
|
export const HairCheck = () => {
|
||||||
const { callObject } = useCallState();
|
const { callObject } = useCallState();
|
||||||
const { localParticipant } = useParticipants();
|
const { localParticipant } = useParticipants();
|
||||||
|
|
@ -29,9 +36,10 @@ export const HairCheck = () => {
|
||||||
const { showDeviceModal, setShowDeviceModal } = useUIState();
|
const { showDeviceModal, setShowDeviceModal } = useUIState();
|
||||||
const [waiting, setWaiting] = useState(false);
|
const [waiting, setWaiting] = useState(false);
|
||||||
const [joining, setJoining] = useState(false);
|
const [joining, setJoining] = useState(false);
|
||||||
|
const [denied, setDenied] = useState();
|
||||||
const [userName, setUserName] = useState('');
|
const [userName, setUserName] = useState('');
|
||||||
|
|
||||||
// Tell Daily to initialise devices (even through we're not yet in a call)
|
// Initialise devices (even though we're not yet in a call)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!callObject) return;
|
if (!callObject) return;
|
||||||
callObject.startCamera();
|
callObject.startCamera();
|
||||||
|
|
@ -46,7 +54,7 @@ export const HairCheck = () => {
|
||||||
// Set the local participants name
|
// Set the local participants name
|
||||||
await callObject.setUserName(userName);
|
await callObject.setUserName(userName);
|
||||||
|
|
||||||
// Attempt to jin the call
|
// Async request access (this will block until the call owner responds to the knock)
|
||||||
const { access } = callObject.accessState();
|
const { access } = callObject.accessState();
|
||||||
await callObject.join();
|
await callObject.join();
|
||||||
|
|
||||||
|
|
@ -61,9 +69,11 @@ export const HairCheck = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (granted) {
|
if (granted) {
|
||||||
|
// Note: we don't have to do any thing here as the call state will mutate
|
||||||
console.log('👋 Access granted');
|
console.log('👋 Access granted');
|
||||||
} else {
|
} else {
|
||||||
console.log('❌ Access denied');
|
console.log('❌ Access denied');
|
||||||
|
setDenied(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -163,7 +173,12 @@ export const HairCheck = () => {
|
||||||
<footer>
|
<footer>
|
||||||
{waiting ? (
|
{waiting ? (
|
||||||
<div className="waiting">
|
<div className="waiting">
|
||||||
<Loader /> <span>Waiting for host to grant access</span>
|
<Loader />
|
||||||
|
{denied ? (
|
||||||
|
<span>Call owner denied request</span>
|
||||||
|
) : (
|
||||||
|
<span>Waiting for host to grant access</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue