@vgroup/dialbox 0.1.27 → 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 -18
- package/esm2020/lib/service/twilio.service.mjs +71 -73
- package/fesm2015/vgroup-dialbox.mjs +101 -92
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +101 -92
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/components/call-progress/incoming-call/incoming-call.component.d.ts +0 -1
- package/lib/service/twilio.service.d.ts +0 -4
- package/package.json +1 -1
|
@@ -1372,8 +1372,6 @@ 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();
|
|
1377
1375
|
this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
|
|
1378
1376
|
this.callType = new BehaviorSubject('NIL');
|
|
1379
1377
|
this.isIncomingCallPicked = new BehaviorSubject(false); // for both incoming and outgoing
|
|
@@ -1391,8 +1389,6 @@ class TwilioService {
|
|
|
1391
1389
|
this.triggerSMSReload = new BehaviorSubject(false);
|
|
1392
1390
|
this.tokenInitialized = false;
|
|
1393
1391
|
this.tokenInitialization$ = null;
|
|
1394
|
-
this.devicePromise = null;
|
|
1395
|
-
this.processedCallSids = new Set();
|
|
1396
1392
|
this.initializeToken();
|
|
1397
1393
|
}
|
|
1398
1394
|
initializeToken() {
|
|
@@ -1413,85 +1409,87 @@ class TwilioService {
|
|
|
1413
1409
|
}
|
|
1414
1410
|
initializeTwilioDevice() {
|
|
1415
1411
|
if (this.tokenInitialized && this.incomingCallToken) {
|
|
1416
|
-
this.initializeDevice()
|
|
1412
|
+
this.initializeDevice();
|
|
1417
1413
|
}
|
|
1418
1414
|
else {
|
|
1419
1415
|
this.initializeToken().subscribe();
|
|
1420
1416
|
}
|
|
1421
1417
|
}
|
|
1422
|
-
initializeDevice() {
|
|
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
|
-
|
|
1455
|
-
|
|
1456
|
-
const onIncoming = (call) => {
|
|
1457
|
-
const callSid = call.parameters['CallSid'];
|
|
1458
|
-
if (callSid && !this.processedCallSids.has(callSid)) {
|
|
1459
|
-
this.processedCallSids.add(callSid);
|
|
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
|
|
1464
|
-
this.currentCall.next(call);
|
|
1465
|
-
this.callType.next('INCOMING');
|
|
1466
|
-
this.currentCallState.next('incoming');
|
|
1467
|
-
this.notificationSerivce.showNotification(call);
|
|
1468
|
-
const callEndHandler = () => {
|
|
1469
|
-
this.processedCallSids.delete(callSid);
|
|
1470
|
-
const currentCalls = this.incomingCalls.getValue().filter(c => c.parameters['CallSid'] !== callSid);
|
|
1471
|
-
this.incomingCalls.next(currentCalls);
|
|
1472
|
-
call.off('disconnect', callEndHandler);
|
|
1473
|
-
call.off('cancel', callEndHandler);
|
|
1474
|
-
};
|
|
1475
|
-
call.on('disconnect', callEndHandler);
|
|
1476
|
-
call.on('cancel', callEndHandler);
|
|
1477
|
-
}
|
|
1478
|
-
else {
|
|
1479
|
-
console.log('Duplicate incoming call event ignored for CallSid:', callSid);
|
|
1480
|
-
}
|
|
1481
|
-
};
|
|
1482
|
-
device.on('registered', onRegistered);
|
|
1483
|
-
device.on('error', onError);
|
|
1484
|
-
device.on('incoming', onIncoming);
|
|
1485
|
-
device.register();
|
|
1486
|
-
});
|
|
1487
|
-
return this.devicePromise;
|
|
1488
|
-
}
|
|
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
|
+
// }
|
|
1489
1452
|
// onIncomingCall(){
|
|
1490
1453
|
// this.device.on('incoming', (call:any) => {
|
|
1491
1454
|
// console.log(call);
|
|
1492
1455
|
// //call.accept();
|
|
1493
1456
|
// });
|
|
1494
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
|
+
}
|
|
1495
1493
|
saveContact(payload) {
|
|
1496
1494
|
const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
|
|
1497
1495
|
return this.http.post(environment.apiUrl + '/utilities/phonebook/add/contacts/manually', payload, httpOptions);
|
|
@@ -1609,15 +1607,34 @@ class IncomingCallComponent {
|
|
|
1609
1607
|
this.selectedIncomingCallInfo = new EventEmitter();
|
|
1610
1608
|
}
|
|
1611
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
|
+
// });
|
|
1612
1617
|
try {
|
|
1613
|
-
this.twilioService.
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1618
|
+
this.twilioService.currentCall.subscribe(call => {
|
|
1619
|
+
if (call) {
|
|
1620
|
+
this.twilioCallData = call;
|
|
1621
|
+
this.twilioAuthId = call.customParameters.get('twilioAuthId');
|
|
1622
|
+
if (!call.parameters) {
|
|
1623
|
+
call.parameters = {};
|
|
1624
|
+
}
|
|
1620
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
|
+
});
|
|
1621
1638
|
}
|
|
1622
1639
|
});
|
|
1623
1640
|
}
|
|
@@ -1640,15 +1657,6 @@ class IncomingCallComponent {
|
|
|
1640
1657
|
}
|
|
1641
1658
|
});
|
|
1642
1659
|
}
|
|
1643
|
-
removeCallFromList(callSid) {
|
|
1644
|
-
if (this.newIncomingCallsList) {
|
|
1645
|
-
this.newIncomingCallsList = this.newIncomingCallsList.filter((c) => c.parameters['CallSid'] !== callSid);
|
|
1646
|
-
this.incomingCallsNewList.emit(this.newIncomingCallsList);
|
|
1647
|
-
if (this.newIncomingCallsList.length === 0) {
|
|
1648
|
-
this.closeIncomingCallDiv.emit({ show: 0, call: null });
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
1660
|
rejectCallFromList(data) {
|
|
1653
1661
|
if (!data)
|
|
1654
1662
|
return;
|
|
@@ -1663,7 +1671,11 @@ class IncomingCallComponent {
|
|
|
1663
1671
|
this.sendIPforIncomingCall(data.customParameters.get('twilioAuthId'), 'answered');
|
|
1664
1672
|
}
|
|
1665
1673
|
if (this.newIncomingCallsList && data && data.parameters && data.parameters.CallSid) {
|
|
1666
|
-
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
|
+
}
|
|
1667
1679
|
}
|
|
1668
1680
|
}
|
|
1669
1681
|
closeIncomingCallWrapper(val) {
|
|
@@ -2158,9 +2170,6 @@ class CallProgressComponent {
|
|
|
2158
2170
|
incomingCallsNewList(data) {
|
|
2159
2171
|
this.newIncomingCallsList = data;
|
|
2160
2172
|
this.incomingCallsNewInfo.emit(this.newIncomingCallsList);
|
|
2161
|
-
if (!data || data.length === 0) {
|
|
2162
|
-
this.incomingCallDiv = false;
|
|
2163
|
-
}
|
|
2164
2173
|
}
|
|
2165
2174
|
selectedIncomingCallInfo(data) {
|
|
2166
2175
|
this.selectedIncomingCall = data;
|