Regression: Fix incoming voip call ringtone is not ringing (#24616)

pull/24619/head
Murtaza Patrawala 4 years ago committed by GitHub
parent 8ceeffc9d6
commit 8703b03e2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/custom-sounds/client/lib/CustomSounds.js
  2. 20
      client/providers/CallProvider/CallProvider.tsx
  3. BIN
      public/sounds/telephone.mp3

@ -33,6 +33,12 @@ class CustomSoundsClass {
extension: 'mp3',
src: getURL('sounds/seasons.mp3'),
});
this.add({
_id: 'telephone',
name: 'Telephone',
extension: 'mp3',
src: getURL('sounds/telephone.mp3'),
});
}
add(sound) {

@ -3,8 +3,11 @@ import React, { useMemo, FC, useRef, useCallback, useEffect, useState } from 're
import { createPortal } from 'react-dom';
import { OutgoingByeRequest } from 'sip.js/lib/core';
import { CustomSounds } from '../../../app/custom-sounds/client';
import { Notifications } from '../../../app/notifications/client';
import { getUserPreference } from '../../../app/utils/client';
import { IVoipRoom } from '../../../definition/IRoom';
import { IUser } from '../../../definition/IUser';
import { WrapUpCallModal } from '../../components/voip/modal/WrapUpCallModal';
import { CallContext, CallContextValue } from '../../contexts/CallContext';
import { useSetModal } from '../../contexts/ModalContext';
@ -16,6 +19,19 @@ import { useUser } from '../../contexts/UserContext';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { isUseVoipClientResultError, isUseVoipClientResultLoading, useVoipClient } from './hooks/useVoipClient';
const startRingback = (user: IUser): void => {
const audioVolume = getUserPreference(user, 'notificationsSoundVolume');
CustomSounds.play('telephone', {
volume: Number((audioVolume / 100).toPrecision(2)),
loop: true,
});
};
const stopRingback = (): void => {
CustomSounds.pause('telephone');
CustomSounds.remove('telephone');
};
export const CallProvider: FC = ({ children }) => {
const voipEnabled = useSetting('VoIP_Enabled');
@ -181,6 +197,10 @@ export const CallProvider: FC = ({ children }) => {
const { registrationInfo, voipClient } = result;
voipClient.on('incomingcall', () => user && startRingback(user));
voipClient.on('callestablished', () => stopRingback());
voipClient.on('callterminated', () => stopRingback());
return {
enabled: true,
ready: true,

Binary file not shown.
Loading…
Cancel
Save