session-desktop/ts/session/utils/RingingManager.ts
Audric Ackermann 48e7a0e25f
Various UI fixes (#2070)
* cleanup unused convo json fields in db

* display a toast if the user is not approved yet on call OFFER received

* enable CBR for calls

* do not update active_at on configMessage if !!active_at

* remove mkdirp dependency

* disable call button if focused convo is blocked

* quote: do not include the full body in quote, but just the first 100

* click on the edit profile qr code padding

* Allow longer input for opengroup join overlay

Fixes #2068

* Fix overlay feature for start new session button

* make ringing depend on redux CALL status

* turn ON read-receipt by default
2021-12-08 14:15:54 +11:00

35 lines
743 B
TypeScript

const sound = './sound/ringing.mp3';
let currentlyRinging = false;
let ringingAudio: HTMLAudioElement | undefined;
function stopRinging() {
if (ringingAudio) {
ringingAudio.pause();
ringingAudio.srcObject = null;
}
}
function startRinging() {
if (!ringingAudio) {
ringingAudio = new Audio(sound);
ringingAudio.loop = true;
ringingAudio.volume = 0.6;
}
void ringingAudio.play().catch(window.log.info);
}
export function getIsRinging() {
return currentlyRinging;
}
export function setIsRinging(isRinging: boolean) {
if (!currentlyRinging && isRinging) {
startRinging();
currentlyRinging = true;
} else if (currentlyRinging && !isRinging) {
stopRinging();
currentlyRinging = false;
}
}