mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-08 20:09:19 +00:00
Ensure leave sound does not play
This commit is contained in:
@@ -117,7 +117,6 @@ import { Avatar, Size as AvatarSize } from "../Avatar";
|
|||||||
import waitingStyles from "./WaitingForJoin.module.css";
|
import waitingStyles from "./WaitingForJoin.module.css";
|
||||||
import { prefetchSounds } from "../soundUtils";
|
import { prefetchSounds } from "../soundUtils";
|
||||||
import { useAudioContext } from "../useAudioContext";
|
import { useAudioContext } from "../useAudioContext";
|
||||||
|
|
||||||
import ringtoneMp3 from "../sound/ringtone.mp3?url";
|
import ringtoneMp3 from "../sound/ringtone.mp3?url";
|
||||||
import ringtoneOgg from "../sound/ringtone.ogg?url";
|
import ringtoneOgg from "../sound/ringtone.ogg?url";
|
||||||
import declineMp3 from "../sound/call_declined.mp3?url";
|
import declineMp3 from "../sound/call_declined.mp3?url";
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import {
|
|||||||
concat,
|
concat,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
endWith,
|
endWith,
|
||||||
|
every,
|
||||||
filter,
|
filter,
|
||||||
forkJoin,
|
forkJoin,
|
||||||
fromEvent,
|
fromEvent,
|
||||||
@@ -49,6 +50,7 @@ import {
|
|||||||
race,
|
race,
|
||||||
scan,
|
scan,
|
||||||
skip,
|
skip,
|
||||||
|
skipWhile,
|
||||||
startWith,
|
startWith,
|
||||||
switchAll,
|
switchAll,
|
||||||
switchMap,
|
switchMap,
|
||||||
@@ -853,17 +855,6 @@ export class CallViewModel extends ViewModel {
|
|||||||
throttleTime(THROTTLE_SOUND_EFFECT_MS),
|
throttleTime(THROTTLE_SOUND_EFFECT_MS),
|
||||||
);
|
);
|
||||||
|
|
||||||
public readonly leaveSoundEffect$ = this.userMedia$.pipe(
|
|
||||||
pairwise(),
|
|
||||||
filter(
|
|
||||||
([prev, current]) =>
|
|
||||||
current.length <= MAX_PARTICIPANT_COUNT_FOR_SOUND &&
|
|
||||||
current.length < prev.length,
|
|
||||||
),
|
|
||||||
map(() => {}),
|
|
||||||
throttleTime(THROTTLE_SOUND_EFFECT_MS),
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of participants currently in the call.
|
* The number of participants currently in the call.
|
||||||
*
|
*
|
||||||
@@ -963,7 +954,9 @@ export class CallViewModel extends ViewModel {
|
|||||||
* - "success": Someone else joined. The call is in a normal state. No audiovisual feedback.
|
* - "success": Someone else joined. The call is in a normal state. No audiovisual feedback.
|
||||||
* - null: EC is configured to never show any waiting for answer state.
|
* - null: EC is configured to never show any waiting for answer state.
|
||||||
*/
|
*/
|
||||||
public readonly callPickupState$ = this.options.waitForCallPickup
|
public readonly callPickupState$: Behavior<
|
||||||
|
"unknown" | "ringing" | "timeout" | "decline" | "success" | null
|
||||||
|
> = this.options.waitForCallPickup
|
||||||
? this.scope.behavior<
|
? this.scope.behavior<
|
||||||
"unknown" | "ringing" | "timeout" | "decline" | "success"
|
"unknown" | "ringing" | "timeout" | "decline" | "success"
|
||||||
>(
|
>(
|
||||||
@@ -983,6 +976,28 @@ export class CallViewModel extends ViewModel {
|
|||||||
)
|
)
|
||||||
: constant(null);
|
: constant(null);
|
||||||
|
|
||||||
|
public readonly callWasSuccessful$ = this.callPickupState$.pipe(
|
||||||
|
every((x) => x !== "success"),
|
||||||
|
map((v) => !v),
|
||||||
|
);
|
||||||
|
|
||||||
|
public readonly leaveSoundEffect$ = combineLatest([
|
||||||
|
this.callWasSuccessful$,
|
||||||
|
this.userMedia$,
|
||||||
|
]).pipe(
|
||||||
|
// Until the call is successful, do not play a leave sound.
|
||||||
|
skipWhile(([c]) => c === false),
|
||||||
|
map(([, userMedia]) => userMedia),
|
||||||
|
pairwise(),
|
||||||
|
filter(
|
||||||
|
([prev, current]) =>
|
||||||
|
current.length <= MAX_PARTICIPANT_COUNT_FOR_SOUND &&
|
||||||
|
current.length < prev.length,
|
||||||
|
),
|
||||||
|
map(() => {}),
|
||||||
|
throttleTime(THROTTLE_SOUND_EFFECT_MS),
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of MediaItems that we want to display, that are of type ScreenShare
|
* List of MediaItems that we want to display, that are of type ScreenShare
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user