mirror of https://github.com/vector-im/riot-web
Merge pull request #6691 from SimonBrandner/fix/agressive-pausing/18588
Pause ringing more aggressivelypull/21833/head
commit
c13b3be600
|
@ -250,7 +250,15 @@ export default class CallHandler extends EventEmitter {
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
private areAnyCallsUnsilenced(): boolean {
|
private areAnyCallsUnsilenced(): boolean {
|
||||||
return this.calls.size > this.silencedCalls.size;
|
for (const call of this.calls.values()) {
|
||||||
|
if (
|
||||||
|
call.state === CallState.Ringing &&
|
||||||
|
!this.isCallSilenced(call.callId)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async checkProtocols(maxTries) {
|
private async checkProtocols(maxTries) {
|
||||||
|
@ -878,6 +886,8 @@ export default class CallHandler extends EventEmitter {
|
||||||
break;
|
break;
|
||||||
case 'hangup':
|
case 'hangup':
|
||||||
case 'reject':
|
case 'reject':
|
||||||
|
this.stopRingingIfPossible(this.calls.get(payload.room_id).callId);
|
||||||
|
|
||||||
if (!this.calls.get(payload.room_id)) {
|
if (!this.calls.get(payload.room_id)) {
|
||||||
return; // no call to hangup
|
return; // no call to hangup
|
||||||
}
|
}
|
||||||
|
@ -890,11 +900,15 @@ export default class CallHandler extends EventEmitter {
|
||||||
// the hangup event away)
|
// the hangup event away)
|
||||||
break;
|
break;
|
||||||
case 'hangup_all':
|
case 'hangup_all':
|
||||||
|
this.stopRingingIfPossible(this.calls.get(payload.room_id).callId);
|
||||||
|
|
||||||
for (const call of this.calls.values()) {
|
for (const call of this.calls.values()) {
|
||||||
call.hangup(CallErrorCode.UserHangup, false);
|
call.hangup(CallErrorCode.UserHangup, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'answer': {
|
case 'answer': {
|
||||||
|
this.stopRingingIfPossible(this.calls.get(payload.room_id).callId);
|
||||||
|
|
||||||
if (!this.calls.has(payload.room_id)) {
|
if (!this.calls.has(payload.room_id)) {
|
||||||
return; // no call to answer
|
return; // no call to answer
|
||||||
}
|
}
|
||||||
|
@ -929,6 +943,12 @@ export default class CallHandler extends EventEmitter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private stopRingingIfPossible(callId: string): void {
|
||||||
|
this.silencedCalls.delete(callId);
|
||||||
|
if (this.areAnyCallsUnsilenced()) return;
|
||||||
|
this.pause(AudioID.Ring);
|
||||||
|
}
|
||||||
|
|
||||||
private async dialNumber(number: string) {
|
private async dialNumber(number: string) {
|
||||||
const results = await this.pstnLookup(number);
|
const results = await this.pstnLookup(number);
|
||||||
if (!results || results.length === 0 || !results[0].userid) {
|
if (!results || results.length === 0 || !results[0].userid) {
|
||||||
|
|
Loading…
Reference in New Issue