@vgroup/dialbox 0.1.26 → 0.1.28
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/call-progress.component.mjs +1 -4
- package/esm2020/lib/components/call-progress/incoming-call/incoming-call.component.mjs +32 -34
- package/esm2020/lib/service/twilio.service.mjs +71 -66
- package/fesm2015/vgroup-dialbox.mjs +101 -101
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +101 -101
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/components/call-progress/incoming-call/incoming-call.component.d.ts +0 -2
- package/lib/service/twilio.service.d.ts +0 -2
- package/package.json +1 -1
|
@@ -1389,8 +1389,6 @@ class TwilioService {
|
|
|
1389
1389
|
this.triggerSMSReload = new BehaviorSubject(false);
|
|
1390
1390
|
this.tokenInitialized = false;
|
|
1391
1391
|
this.tokenInitialization$ = null;
|
|
1392
|
-
this.devicePromise = null;
|
|
1393
|
-
this.processedCallSids = new Set();
|
|
1394
1392
|
this.initializeToken();
|
|
1395
1393
|
}
|
|
1396
1394
|
initializeToken() {
|
|
@@ -1411,80 +1409,87 @@ class TwilioService {
|
|
|
1411
1409
|
}
|
|
1412
1410
|
initializeTwilioDevice() {
|
|
1413
1411
|
if (this.tokenInitialized && this.incomingCallToken) {
|
|
1414
|
-
this.initializeDevice()
|
|
1412
|
+
this.initializeDevice();
|
|
1415
1413
|
}
|
|
1416
1414
|
else {
|
|
1417
1415
|
this.initializeToken().subscribe();
|
|
1418
1416
|
}
|
|
1419
1417
|
}
|
|
1420
|
-
initializeDevice() {
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
const onIncoming = (call) => {
|
|
1455
|
-
const callSid = call.parameters['CallSid'];
|
|
1456
|
-
if (callSid && !this.processedCallSids.has(callSid)) {
|
|
1457
|
-
this.processedCallSids.add(callSid);
|
|
1458
|
-
console.log('New incoming call:', callSid);
|
|
1459
|
-
this.currentCall.next(call);
|
|
1460
|
-
this.callType.next('INCOMING');
|
|
1461
|
-
this.currentCallState.next('incoming');
|
|
1462
|
-
this.notificationSerivce.showNotification(call);
|
|
1463
|
-
const callEndHandler = () => {
|
|
1464
|
-
this.processedCallSids.delete(callSid);
|
|
1465
|
-
call.off('disconnect', callEndHandler);
|
|
1466
|
-
call.off('cancel', callEndHandler);
|
|
1467
|
-
};
|
|
1468
|
-
call.on('disconnect', callEndHandler);
|
|
1469
|
-
call.on('cancel', callEndHandler);
|
|
1470
|
-
}
|
|
1471
|
-
else {
|
|
1472
|
-
console.log('Duplicate incoming call event ignored for CallSid:', callSid);
|
|
1473
|
-
}
|
|
1474
|
-
};
|
|
1475
|
-
device.on('registered', onRegistered);
|
|
1476
|
-
device.on('error', onError);
|
|
1477
|
-
device.on('incoming', onIncoming);
|
|
1478
|
-
device.register();
|
|
1479
|
-
});
|
|
1480
|
-
return this.devicePromise;
|
|
1481
|
-
}
|
|
1418
|
+
// private initializeDevice() {
|
|
1419
|
+
// if (this.device) {
|
|
1420
|
+
// this.device.destroy();
|
|
1421
|
+
// }
|
|
1422
|
+
// if (!this.incomingCallToken) {
|
|
1423
|
+
// console.error('No Twilio token available');
|
|
1424
|
+
// return;
|
|
1425
|
+
// }
|
|
1426
|
+
// this.device = new Device(this.incomingCallToken, {
|
|
1427
|
+
// allowIncomingWhileBusy: true,
|
|
1428
|
+
// closeProtection: true
|
|
1429
|
+
// });
|
|
1430
|
+
// console.log("device created")
|
|
1431
|
+
// this.device.register();
|
|
1432
|
+
// this.device.on('incoming', (call: Call) => {
|
|
1433
|
+
// console.log("incoming call",call)
|
|
1434
|
+
// this.currentCall.next(call);
|
|
1435
|
+
// this.callType.next('INCOMING');
|
|
1436
|
+
// this.currentCallState.next('incoming');
|
|
1437
|
+
// this.notificationSerivce.showNotification(call);
|
|
1438
|
+
// });
|
|
1439
|
+
// this.device.on('error', (error: any) => {
|
|
1440
|
+
// console.error('Twilio Device Error:', error);
|
|
1441
|
+
// // Reset initialization state on error to allow retry
|
|
1442
|
+
// this.tokenInitialized = false;
|
|
1443
|
+
// });
|
|
1444
|
+
// this.device.on('registered', () => {
|
|
1445
|
+
// console.log('Twilio Device registered successfully');
|
|
1446
|
+
// });
|
|
1447
|
+
// this.device.on('unregistered', () => {
|
|
1448
|
+
// console.log('Twilio Device unregistered');
|
|
1449
|
+
// this.tokenInitialized = false;
|
|
1450
|
+
// });
|
|
1451
|
+
// }
|
|
1482
1452
|
// onIncomingCall(){
|
|
1483
1453
|
// this.device.on('incoming', (call:any) => {
|
|
1484
1454
|
// console.log(call);
|
|
1485
1455
|
// //call.accept();
|
|
1486
1456
|
// });
|
|
1487
1457
|
// }
|
|
1458
|
+
initializeDevice() {
|
|
1459
|
+
if (this.device) {
|
|
1460
|
+
this.device.destroy();
|
|
1461
|
+
this.device = null;
|
|
1462
|
+
}
|
|
1463
|
+
if (!this.incomingCallToken) {
|
|
1464
|
+
console.error('No Twilio token available');
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
this.device = new Device(this.incomingCallToken, {
|
|
1468
|
+
allowIncomingWhileBusy: true,
|
|
1469
|
+
closeProtection: true
|
|
1470
|
+
});
|
|
1471
|
+
this.device.register();
|
|
1472
|
+
// Remove previous handlers to avoid duplicates
|
|
1473
|
+
this.device.removeAllListeners('incoming');
|
|
1474
|
+
this.device.on('incoming', (call) => {
|
|
1475
|
+
console.log("incoming call", call);
|
|
1476
|
+
this.currentCall.next(call); // ✅ fires only once per real call
|
|
1477
|
+
this.callType.next('INCOMING');
|
|
1478
|
+
this.currentCallState.next('incoming');
|
|
1479
|
+
this.notificationSerivce.showNotification(call);
|
|
1480
|
+
});
|
|
1481
|
+
this.device.on('error', (error) => {
|
|
1482
|
+
console.error('Twilio Device Error:', error);
|
|
1483
|
+
this.tokenInitialized = false;
|
|
1484
|
+
});
|
|
1485
|
+
this.device.on('registered', () => {
|
|
1486
|
+
console.log('Twilio Device registered successfully');
|
|
1487
|
+
});
|
|
1488
|
+
this.device.on('unregistered', () => {
|
|
1489
|
+
console.log('Twilio Device unregistered');
|
|
1490
|
+
this.tokenInitialized = false;
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1488
1493
|
saveContact(payload) {
|
|
1489
1494
|
const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
|
|
1490
1495
|
return this.http.post(environment.apiUrl + '/utilities/phonebook/add/contacts/manually', payload, httpOptions);
|
|
@@ -1602,10 +1607,34 @@ class IncomingCallComponent {
|
|
|
1602
1607
|
this.selectedIncomingCallInfo = new EventEmitter();
|
|
1603
1608
|
}
|
|
1604
1609
|
ngOnInit() {
|
|
1610
|
+
// this.twilioService.currentCall.subscribe((call: any) => {
|
|
1611
|
+
// if (call) {
|
|
1612
|
+
// this.twilioCallData = call;
|
|
1613
|
+
// this.notificationSerivce.showNotification(call);
|
|
1614
|
+
// // Handle the call UI
|
|
1615
|
+
// }
|
|
1616
|
+
// });
|
|
1605
1617
|
try {
|
|
1606
1618
|
this.twilioService.currentCall.subscribe(call => {
|
|
1607
|
-
if (call
|
|
1608
|
-
this.
|
|
1619
|
+
if (call) {
|
|
1620
|
+
this.twilioCallData = call;
|
|
1621
|
+
this.twilioAuthId = call.customParameters.get('twilioAuthId');
|
|
1622
|
+
if (!call.parameters) {
|
|
1623
|
+
call.parameters = {};
|
|
1624
|
+
}
|
|
1625
|
+
this.sendIPforIncomingCall(this.twilioAuthId, '');
|
|
1626
|
+
call.on('cancel', () => {
|
|
1627
|
+
if (this.incomingCallData && this.incomingCallData.parameters && this.incomingCallData.parameters.CallSid) {
|
|
1628
|
+
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== this.incomingCallData.parameters.CallSid);
|
|
1629
|
+
}
|
|
1630
|
+
this.rejectCallFromList(call);
|
|
1631
|
+
});
|
|
1632
|
+
call.on('disconnect', () => {
|
|
1633
|
+
if (this.incomingCallData && this.incomingCallData.parameters && this.incomingCallData.parameters.CallSid) {
|
|
1634
|
+
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== this.incomingCallData.parameters.CallSid);
|
|
1635
|
+
}
|
|
1636
|
+
this.rejectCallFromList(call);
|
|
1637
|
+
});
|
|
1609
1638
|
}
|
|
1610
1639
|
});
|
|
1611
1640
|
}
|
|
@@ -1613,27 +1642,6 @@ class IncomingCallComponent {
|
|
|
1613
1642
|
console.log(e);
|
|
1614
1643
|
}
|
|
1615
1644
|
}
|
|
1616
|
-
addCallToList(call) {
|
|
1617
|
-
if (!this.newIncomingCallsList) {
|
|
1618
|
-
this.newIncomingCallsList = [];
|
|
1619
|
-
}
|
|
1620
|
-
const callSid = call.parameters['CallSid'];
|
|
1621
|
-
const existingCall = this.newIncomingCallsList.find((c) => c.parameters['CallSid'] === callSid);
|
|
1622
|
-
if (!existingCall) {
|
|
1623
|
-
this.newIncomingCallsList.push(call);
|
|
1624
|
-
this.incomingCallsNewList.emit([...this.newIncomingCallsList]);
|
|
1625
|
-
if (!this.twilioCallData) {
|
|
1626
|
-
this.twilioCallData = call;
|
|
1627
|
-
this.twilioAuthId = call.customParameters.get('twilioAuthId');
|
|
1628
|
-
this.sendIPforIncomingCall(this.twilioAuthId, '');
|
|
1629
|
-
}
|
|
1630
|
-
call.on('cancel', () => this.removeCallFromList(callSid));
|
|
1631
|
-
call.on('disconnect', () => this.removeCallFromList(callSid));
|
|
1632
|
-
}
|
|
1633
|
-
else {
|
|
1634
|
-
console.log('Call already in list, not adding again.');
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
1645
|
acceptCallFromList(data) {
|
|
1638
1646
|
data.accept();
|
|
1639
1647
|
// data.parameters['isCallConnected'] = true;
|
|
@@ -1649,15 +1657,6 @@ class IncomingCallComponent {
|
|
|
1649
1657
|
}
|
|
1650
1658
|
});
|
|
1651
1659
|
}
|
|
1652
|
-
removeCallFromList(callSid) {
|
|
1653
|
-
if (this.newIncomingCallsList) {
|
|
1654
|
-
this.newIncomingCallsList = this.newIncomingCallsList.filter((c) => c.parameters['CallSid'] !== callSid);
|
|
1655
|
-
this.incomingCallsNewList.emit(this.newIncomingCallsList);
|
|
1656
|
-
if (this.newIncomingCallsList.length === 0) {
|
|
1657
|
-
this.closeIncomingCallDiv.emit({ show: 0, call: null });
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
1660
|
rejectCallFromList(data) {
|
|
1662
1661
|
if (!data)
|
|
1663
1662
|
return;
|
|
@@ -1672,7 +1671,11 @@ class IncomingCallComponent {
|
|
|
1672
1671
|
this.sendIPforIncomingCall(data.customParameters.get('twilioAuthId'), 'answered');
|
|
1673
1672
|
}
|
|
1674
1673
|
if (this.newIncomingCallsList && data && data.parameters && data.parameters.CallSid) {
|
|
1675
|
-
this.
|
|
1674
|
+
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== data.parameters.CallSid);
|
|
1675
|
+
this.incomingCallsNewList.emit(this.newIncomingCallsList);
|
|
1676
|
+
if (this.newIncomingCallsList.length == 0) {
|
|
1677
|
+
this.closeIncomingCallDiv.emit({ show: 0, call: data });
|
|
1678
|
+
}
|
|
1676
1679
|
}
|
|
1677
1680
|
}
|
|
1678
1681
|
closeIncomingCallWrapper(val) {
|
|
@@ -2167,9 +2170,6 @@ class CallProgressComponent {
|
|
|
2167
2170
|
incomingCallsNewList(data) {
|
|
2168
2171
|
this.newIncomingCallsList = data;
|
|
2169
2172
|
this.incomingCallsNewInfo.emit(this.newIncomingCallsList);
|
|
2170
|
-
if (!data || data.length === 0) {
|
|
2171
|
-
this.incomingCallDiv = false;
|
|
2172
|
-
}
|
|
2173
2173
|
}
|
|
2174
2174
|
selectedIncomingCallInfo(data) {
|
|
2175
2175
|
this.selectedIncomingCall = data;
|