@@ -87,7 +87,6 @@ export default class Adapter extends AdapterModuleCore {
8787 this . _loggedIn = null ;
8888 this . _regionCountryCode = null ;
8989 this . _lastActiveCalls = [ ] ;
90- this . _lastEndedActiveCallMap = { } ;
9190 this . _lastActiveCallLogMap = { } ;
9291 this . _callWith = null ;
9392
@@ -220,18 +219,18 @@ export default class Adapter extends AdapterModuleCore {
220219 if ( this . _disableInactiveTabCallEvent && this . _tabManager . ready && ( ! this . _tabManager . active ) ) {
221220 return ;
222221 }
223- if ( this . _lastActiveCalls === this . _presence . calls ) {
222+ if ( this . _lastActiveCalls === this . _presence . activeCalls ) {
224223 return ;
225224 }
226225 const lastActiveCallsMap = { } ;
227226 this . _lastActiveCalls . forEach ( ( call ) => {
228227 lastActiveCallsMap [ `${ call . sessionId } ${ call . direction } ` ] = call ;
229228 } ) ;
230- this . _lastActiveCalls = this . _presence . calls ;
229+ this . _lastActiveCalls = this . _presence . activeCalls ;
231230 const changedCalls = [ ] ;
232231 // Ended Call is not in this._presence.calls
233232 // So if one call existed in last calls and not existed in new calls, it is ended
234- this . _presence . calls . forEach ( ( call ) => {
233+ this . _presence . activeCalls . forEach ( ( call ) => {
235234 const oldCall = lastActiveCallsMap [ `${ call . sessionId } ${ call . direction } ` ] ;
236235 if ( ! oldCall ) {
237236 changedCalls . push ( { ...call } ) ;
@@ -243,30 +242,13 @@ export default class Adapter extends AdapterModuleCore {
243242 ) {
244243 changedCalls . push ( { ...call } ) ;
245244 }
246- delete lastActiveCallsMap [ `${ call . sessionId } ${ call . direction } ` ] ;
247- } ) ;
248- const endedActiveCallMap = this . _lastEndedActiveCallMap ;
249- this . _lastEndedActiveCallMap = { } ;
250- // add ended call
251- Object . keys ( lastActiveCallsMap ) . forEach ( ( callId ) => {
252- const endedCall = lastActiveCallsMap [ callId ] ;
253- this . _lastEndedActiveCallMap [ callId ] = endedCall ;
254- if ( endedActiveCallMap [ callId ] ) {
255- return ;
256- }
257- const missed = ( endedCall . telephonyStatus === telephonyStatus . ringing ) ;
258- changedCalls . push ( {
259- ...endedCall ,
260- telephonyStatus : telephonyStatus . noCall ,
261- terminationType : terminationTypes . final ,
262- missed,
263- endTime : missed ? null : Date . now ( ) ,
264- } ) ;
265245 } ) ;
266246 this . _sendRingoutCallNotification ( changedCalls ) ;
267247 this . _sendActiveCallNotification ( changedCalls ) ;
268248 }
269249
250+ // map active call with active call log from this._activeCalls module
251+ // active call log has some delay, so wait CALL_NOTIFY_DELAY
270252 async _sendActiveCallNotification ( activeCalls ) {
271253 await sleep ( CALL_NOTIFY_DELAY ) ;
272254 const activeCallLogMap = { } ;
0 commit comments