mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-30 19:39:22 +00:00
@@ -372,16 +372,23 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// When waiting for pickup, loop a waiting sound
|
// When waiting for pickup, loop a waiting sound
|
||||||
|
const [playing, setPlaying] = useState(false);
|
||||||
useEffect((): void | (() => void) => {
|
useEffect((): void | (() => void) => {
|
||||||
if (callPickupState !== "ringing") return;
|
if (callPickupState !== "ringing") return;
|
||||||
// play immediately and then every ~2.5s while in ringing
|
setPlaying(true);
|
||||||
void pickupPhaseAudio?.playSound("waiting");
|
// play and then wait for 1.5s
|
||||||
const id = window.setInterval(
|
const playSoundAndWait = async (): Promise<void> => {
|
||||||
() => void pickupPhaseAudio?.playSound("waiting"),
|
await pickupPhaseAudio?.playSound("waiting");
|
||||||
2500,
|
await new Promise((res) => setTimeout(res, 1500));
|
||||||
);
|
};
|
||||||
return (): void => window.clearInterval(id);
|
const startPlaying = async (): Promise<void> => {
|
||||||
}, [callPickupState, pickupPhaseAudio]);
|
while (playing) {
|
||||||
|
await playSoundAndWait();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
void startPlaying();
|
||||||
|
return (): void => setPlaying(false);
|
||||||
|
}, [callPickupState, pickupPhaseAudio, playing]);
|
||||||
|
|
||||||
// Waiting UI overlay
|
// Waiting UI overlay
|
||||||
const waitingOverlay: JSX.Element | null = useMemo(() => {
|
const waitingOverlay: JSX.Element | null = useMemo(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user