mirror of
https://github.com/vector-im/element-call.git
synced 2026-06-30 18:02:56 +00:00
Improve internal model of ringing, expose ringing intent to call UI
I found our code's internal model of ringing a little overgrown (it had superfluous states like 'unknown') and difficult to extend with metadata or callbacks relating to ring attempts. By modeling ringing instead as a stream of ring attempts, where each attempt has an intent, a recipient, and an eventual outcome (accept/decline/timeout), I find it more natural to work with. This makes room for a future 'try again' callback to allow ringing someone again after a timeout, and also forced me to look for a simpler solution to the duplicate leave sound effects. I exposed the intent of the ringing attempt to the call UI so I can later use it in the header.
This commit is contained in:
@@ -114,7 +114,7 @@ interface Props<S extends string> {
|
||||
}
|
||||
|
||||
interface UseAudioContext<S extends string> {
|
||||
playSound(soundName: S, volumeOverwrite?: number): Promise<void>;
|
||||
playSound(soundName: S): Promise<void>;
|
||||
playSoundLooping(soundName: S, delayS?: number): () => Promise<void>;
|
||||
/**
|
||||
* Map of sound name to duration in seconds.
|
||||
@@ -195,7 +195,7 @@ export function useAudioContext<S extends string>(
|
||||
}
|
||||
|
||||
return {
|
||||
playSound: async (name, volumeOverwrite?: number): Promise<void> => {
|
||||
playSound: async (name): Promise<void> => {
|
||||
if (!audioBuffers[name]) {
|
||||
logger.debug(`Tried to play a sound that wasn't buffered (${name})`);
|
||||
return;
|
||||
@@ -203,7 +203,7 @@ export function useAudioContext<S extends string>(
|
||||
return playSound(
|
||||
audioContext,
|
||||
audioBuffers[name],
|
||||
volumeOverwrite ?? soundEffectVolume * earpieceVolume,
|
||||
soundEffectVolume * earpieceVolume,
|
||||
earpiecePan,
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user