@vgroup/dialbox 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1372,6 +1372,8 @@ class TwilioService {
1372
1372
  this.notificationSerivce = notificationSerivce;
1373
1373
  this.openInProgressDialpad = new BehaviorSubject(false);
1374
1374
  this.currentCall = new BehaviorSubject(null);
1375
+ this.incomingCalls = new BehaviorSubject([]);
1376
+ this.incomingCalls$ = this.incomingCalls.asObservable();
1375
1377
  this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
1376
1378
  this.callType = new BehaviorSubject('NIL');
1377
1379
  this.isIncomingCallPicked = new BehaviorSubject(false); // for both incoming and outgoing
@@ -1456,9 +1458,17 @@ class TwilioService {
1456
1458
  if (callSid && !this.processedCallSids.has(callSid)) {
1457
1459
  this.processedCallSids.add(callSid);
1458
1460
  console.log('New incoming call:', callSid);
1461
+ const currentCalls = this.incomingCalls.getValue();
1462
+ this.incomingCalls.next([...currentCalls, call]);
1463
+ // The original currentCall can still represent the most recent call for single-call contexts
1459
1464
  this.currentCall.next(call);
1465
+ this.callType.next('INCOMING');
1466
+ this.currentCallState.next('incoming');
1467
+ this.notificationSerivce.showNotification(call);
1460
1468
  const callEndHandler = () => {
1461
1469
  this.processedCallSids.delete(callSid);
1470
+ const currentCalls = this.incomingCalls.getValue().filter(c => c.parameters['CallSid'] !== callSid);
1471
+ this.incomingCalls.next(currentCalls);
1462
1472
  call.off('disconnect', callEndHandler);
1463
1473
  call.off('cancel', callEndHandler);
1464
1474
  };
@@ -1600,9 +1610,14 @@ class IncomingCallComponent {
1600
1610
  }
1601
1611
  ngOnInit() {
1602
1612
  try {
1603
- this.twilioService.currentCall.subscribe(call => {
1604
- if (call && call.parameters['CallSid']) {
1605
- this.addCallToList(call);
1613
+ this.twilioService.incomingCalls$.subscribe(calls => {
1614
+ this.newIncomingCallsList = calls;
1615
+ this.incomingCallsNewList.emit(this.newIncomingCallsList);
1616
+ if (calls.length > 0 && !this.twilioCallData) {
1617
+ const firstCall = calls[0];
1618
+ this.twilioCallData = firstCall;
1619
+ this.twilioAuthId = firstCall.customParameters.get('twilioAuthId');
1620
+ this.sendIPforIncomingCall(this.twilioAuthId, '');
1606
1621
  }
1607
1622
  });
1608
1623
  }
@@ -1610,22 +1625,6 @@ class IncomingCallComponent {
1610
1625
  console.log(e);
1611
1626
  }
1612
1627
  }
1613
- addCallToList(call) {
1614
- if (!this.newIncomingCallsList) {
1615
- this.newIncomingCallsList = [];
1616
- }
1617
- const callSid = call.parameters['CallSid'];
1618
- // The service now handles de-duplication, so we just add the call.
1619
- this.newIncomingCallsList.push(call);
1620
- this.incomingCallsNewList.emit([...this.newIncomingCallsList]);
1621
- if (!this.twilioCallData) {
1622
- this.twilioCallData = call;
1623
- this.twilioAuthId = call.customParameters.get('twilioAuthId');
1624
- this.sendIPforIncomingCall(this.twilioAuthId, '');
1625
- }
1626
- call.on('cancel', () => this.removeCallFromList(callSid));
1627
- call.on('disconnect', () => this.removeCallFromList(callSid));
1628
- }
1629
1628
  acceptCallFromList(data) {
1630
1629
  data.accept();
1631
1630
  // data.parameters['isCallConnected'] = true;