@vgroup/dialbox 0.1.21 → 0.1.22
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.
- package/esm2020/lib/components/call-progress/incoming-call/incoming-call.component.mjs +59 -25
- package/fesm2015/vgroup-dialbox.mjs +60 -24
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +58 -24
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/components/call-progress/incoming-call/incoming-call.component.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1582,23 +1582,30 @@ class IncomingCallComponent {
|
|
|
1582
1582
|
try {
|
|
1583
1583
|
this.twilioService.currentCall.subscribe(call => {
|
|
1584
1584
|
if (call) {
|
|
1585
|
+
const callSid = call.parameters?.['CallSid'];
|
|
1586
|
+
if (!callSid)
|
|
1587
|
+
return;
|
|
1588
|
+
// Check if this call already exists in the list
|
|
1589
|
+
const callExists = this.newIncomingCallsList?.some((item) => item.parameters?.['CallSid'] === callSid);
|
|
1590
|
+
if (callExists) {
|
|
1591
|
+
console.log('Call already exists in the list:', callSid);
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1585
1594
|
this.twilioCallData = call;
|
|
1586
|
-
this.twilioAuthId = call.customParameters
|
|
1595
|
+
this.twilioAuthId = call.customParameters?.get('twilioAuthId');
|
|
1587
1596
|
if (!call.parameters) {
|
|
1588
1597
|
call.parameters = {};
|
|
1589
1598
|
}
|
|
1599
|
+
// Add call to the list
|
|
1600
|
+
this.newIncomingCallsList = [...(this.newIncomingCallsList || []), call];
|
|
1601
|
+
this.incomingCallsNewList.emit(this.newIncomingCallsList);
|
|
1590
1602
|
this.sendIPforIncomingCall(this.twilioAuthId, '');
|
|
1603
|
+
// Set up event handlers for the call
|
|
1591
1604
|
call.on('cancel', () => {
|
|
1592
|
-
|
|
1593
|
-
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== this.incomingCallData.parameters.CallSid);
|
|
1594
|
-
}
|
|
1595
|
-
this.rejectCallFromList(call);
|
|
1605
|
+
this.handleCallEnd(call, callSid);
|
|
1596
1606
|
});
|
|
1597
1607
|
call.on('disconnect', () => {
|
|
1598
|
-
|
|
1599
|
-
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== this.incomingCallData.parameters.CallSid);
|
|
1600
|
-
}
|
|
1601
|
-
this.rejectCallFromList(call);
|
|
1608
|
+
this.handleCallEnd(call, callSid);
|
|
1602
1609
|
});
|
|
1603
1610
|
}
|
|
1604
1611
|
});
|
|
@@ -1622,25 +1629,52 @@ class IncomingCallComponent {
|
|
|
1622
1629
|
}
|
|
1623
1630
|
});
|
|
1624
1631
|
}
|
|
1632
|
+
// Helper method to handle call end events
|
|
1633
|
+
handleCallEnd(call, callSid) {
|
|
1634
|
+
if (!callSid)
|
|
1635
|
+
return;
|
|
1636
|
+
// Remove call from the list
|
|
1637
|
+
if (this.newIncomingCallsList) {
|
|
1638
|
+
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters?.['CallSid'] !== callSid);
|
|
1639
|
+
this.incomingCallsNewList.emit([...this.newIncomingCallsList]);
|
|
1640
|
+
// Close UI if no more calls
|
|
1641
|
+
if (this.newIncomingCallsList.length === 0) {
|
|
1642
|
+
this.closeIncomingCallDiv.emit({ show: 0, call });
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1625
1646
|
rejectCallFromList(data) {
|
|
1626
1647
|
if (!data)
|
|
1627
1648
|
return;
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
data.
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
if (this.newIncomingCallsList && data && data.parameters && data.parameters.CallSid) {
|
|
1639
|
-
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== data.parameters.CallSid);
|
|
1640
|
-
this.incomingCallsNewList.emit(this.newIncomingCallsList);
|
|
1641
|
-
if (this.newIncomingCallsList.length == 0) {
|
|
1642
|
-
this.closeIncomingCallDiv.emit({ show: 0, call: data });
|
|
1649
|
+
const callSid = data.parameters?.['CallSid'];
|
|
1650
|
+
if (!callSid)
|
|
1651
|
+
return;
|
|
1652
|
+
try {
|
|
1653
|
+
// Try to reject or disconnect the call
|
|
1654
|
+
if (typeof data.reject === 'function') {
|
|
1655
|
+
data.reject();
|
|
1656
|
+
}
|
|
1657
|
+
else if (typeof data.disconnect === 'function') {
|
|
1658
|
+
data.disconnect();
|
|
1643
1659
|
}
|
|
1660
|
+
// Update call status
|
|
1661
|
+
if (data.parameters) {
|
|
1662
|
+
data.parameters['isCallConnected'] = false;
|
|
1663
|
+
}
|
|
1664
|
+
// Update call status on the server
|
|
1665
|
+
if (data.customParameters) {
|
|
1666
|
+
const twilioAuthId = data.customParameters.get('twilioAuthId');
|
|
1667
|
+
if (twilioAuthId) {
|
|
1668
|
+
this.sendIPforIncomingCall(twilioAuthId, 'completed');
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
// Remove call from the list
|
|
1672
|
+
this.handleCallEnd(data, callSid);
|
|
1673
|
+
}
|
|
1674
|
+
catch (error) {
|
|
1675
|
+
console.error('Error rejecting call:', error);
|
|
1676
|
+
// Make sure to clean up even if there's an error
|
|
1677
|
+
this.handleCallEnd(data, callSid);
|
|
1644
1678
|
}
|
|
1645
1679
|
}
|
|
1646
1680
|
closeIncomingCallWrapper(val) {
|