Fix incoming call ringtone by awaiting the playout
This commit is contained in:
parent
126b828f46
commit
c6d5607b8c
1 changed files with 20 additions and 10 deletions
|
@ -88,6 +88,7 @@ export type SetVideoRendererType = {
|
||||||
|
|
||||||
const ACCEPT_CALL = 'calling/ACCEPT_CALL';
|
const ACCEPT_CALL = 'calling/ACCEPT_CALL';
|
||||||
const CALL_STATE_CHANGE = 'calling/CALL_STATE_CHANGE';
|
const CALL_STATE_CHANGE = 'calling/CALL_STATE_CHANGE';
|
||||||
|
const CALL_STATE_CHANGE_FULFILLED = 'calling/CALL_STATE_CHANGE_FULFILLED';
|
||||||
const DECLINE_CALL = 'calling/DECLINE_CALL';
|
const DECLINE_CALL = 'calling/DECLINE_CALL';
|
||||||
const HANG_UP = 'calling/HANG_UP';
|
const HANG_UP = 'calling/HANG_UP';
|
||||||
const INCOMING_CALL = 'calling/INCOMING_CALL';
|
const INCOMING_CALL = 'calling/INCOMING_CALL';
|
||||||
|
@ -104,6 +105,11 @@ type AcceptCallActionType = {
|
||||||
|
|
||||||
type CallStateChangeActionType = {
|
type CallStateChangeActionType = {
|
||||||
type: 'calling/CALL_STATE_CHANGE';
|
type: 'calling/CALL_STATE_CHANGE';
|
||||||
|
payload: Promise<CallStateChangeType>;
|
||||||
|
};
|
||||||
|
|
||||||
|
type CallStateChangeFulfilledActionType = {
|
||||||
|
type: 'calling/CALL_STATE_CHANGE_FULFILLED';
|
||||||
payload: CallStateChangeType;
|
payload: CallStateChangeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,6 +156,7 @@ type SetLocalVideoFulfilledActionType = {
|
||||||
export type CallingActionType =
|
export type CallingActionType =
|
||||||
| AcceptCallActionType
|
| AcceptCallActionType
|
||||||
| CallStateChangeActionType
|
| CallStateChangeActionType
|
||||||
|
| CallStateChangeFulfilledActionType
|
||||||
| DeclineCallActionType
|
| DeclineCallActionType
|
||||||
| HangUpActionType
|
| HangUpActionType
|
||||||
| IncomingCallActionType
|
| IncomingCallActionType
|
||||||
|
@ -182,13 +189,20 @@ function acceptCall(
|
||||||
function callStateChange(
|
function callStateChange(
|
||||||
payload: CallStateChangeType
|
payload: CallStateChangeType
|
||||||
): CallStateChangeActionType {
|
): CallStateChangeActionType {
|
||||||
|
return {
|
||||||
|
type: CALL_STATE_CHANGE,
|
||||||
|
payload: doCallStateChange(payload),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doCallStateChange(
|
||||||
|
payload: CallStateChangeType
|
||||||
|
): Promise<CallStateChangeType> {
|
||||||
const { callDetails, callState } = payload;
|
const { callDetails, callState } = payload;
|
||||||
const { isIncoming } = callDetails;
|
const { isIncoming } = callDetails;
|
||||||
if (callState === CallState.Ringing && isIncoming) {
|
if (callState === CallState.Ringing && isIncoming) {
|
||||||
// tslint:disable-next-line no-floating-promises
|
await callingTones.playRingtone();
|
||||||
callingTones.playRingtone();
|
await showCallNotification(callDetails);
|
||||||
// tslint:disable-next-line no-floating-promises
|
|
||||||
showCallNotification(callDetails);
|
|
||||||
bounceAppIconStart();
|
bounceAppIconStart();
|
||||||
}
|
}
|
||||||
if (callState !== CallState.Ringing) {
|
if (callState !== CallState.Ringing) {
|
||||||
|
@ -199,11 +213,7 @@ function callStateChange(
|
||||||
// tslint:disable-next-line no-floating-promises
|
// tslint:disable-next-line no-floating-promises
|
||||||
callingTones.playEndCall();
|
callingTones.playEndCall();
|
||||||
}
|
}
|
||||||
|
return payload;
|
||||||
return {
|
|
||||||
type: CALL_STATE_CHANGE,
|
|
||||||
payload,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showCallNotification(callDetails: CallDetailsType) {
|
async function showCallNotification(callDetails: CallDetailsType) {
|
||||||
|
@ -382,7 +392,7 @@ export function reducer(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.type === CALL_STATE_CHANGE) {
|
if (action.type === CALL_STATE_CHANGE_FULFILLED) {
|
||||||
if (action.payload.callState === CallState.Ended) {
|
if (action.payload.callState === CallState.Ended) {
|
||||||
return getEmptyState();
|
return getEmptyState();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue