@vgroup/dialbox 0.1.27 → 0.1.29
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/dialbox.component.mjs +2 -2
- package/esm2020/lib/service/twilio.service.mjs +31 -67
- package/fesm2015/vgroup-dialbox.mjs +62 -87
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +62 -87
- 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() {
|
|
@@ -1403,6 +1399,7 @@ class TwilioService {
|
|
|
1403
1399
|
this.incomingCallToken = data.token;
|
|
1404
1400
|
localStorage.setItem('in-token', data.token);
|
|
1405
1401
|
this.tokenInitialized = true;
|
|
1402
|
+
console.log('dfdfdsfdsfds');
|
|
1406
1403
|
this.initializeDevice();
|
|
1407
1404
|
}), catchError(error => {
|
|
1408
1405
|
console.error('Error initializing Twilio token:', error);
|
|
@@ -1413,78 +1410,45 @@ class TwilioService {
|
|
|
1413
1410
|
}
|
|
1414
1411
|
initializeTwilioDevice() {
|
|
1415
1412
|
if (this.tokenInitialized && this.incomingCallToken) {
|
|
1416
|
-
this.initializeDevice()
|
|
1413
|
+
this.initializeDevice();
|
|
1417
1414
|
}
|
|
1418
1415
|
else {
|
|
1419
1416
|
this.initializeToken().subscribe();
|
|
1420
1417
|
}
|
|
1421
1418
|
}
|
|
1422
1419
|
initializeDevice() {
|
|
1423
|
-
if (this.devicePromise) {
|
|
1424
|
-
return this.devicePromise;
|
|
1425
|
-
}
|
|
1426
|
-
const token = this.incomingCallToken;
|
|
1427
|
-
if (!token) {
|
|
1428
|
-
return Promise.reject('No Twilio token available');
|
|
1429
|
-
}
|
|
1430
|
-
// Destroy any existing device before creating a new one
|
|
1431
1420
|
if (this.device) {
|
|
1432
1421
|
this.device.destroy();
|
|
1433
1422
|
}
|
|
1434
|
-
this.
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
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();
|
|
1423
|
+
if (!this.incomingCallToken) {
|
|
1424
|
+
console.error('No Twilio token available');
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
this.device = new Device(this.incomingCallToken, {
|
|
1428
|
+
allowIncomingWhileBusy: true,
|
|
1429
|
+
closeProtection: true
|
|
1430
|
+
});
|
|
1431
|
+
console.log("device created");
|
|
1432
|
+
this.device.register();
|
|
1433
|
+
this.device.on('incoming', (call) => {
|
|
1434
|
+
console.log("incoming call", call);
|
|
1435
|
+
this.currentCall.next(call);
|
|
1436
|
+
this.callType.next('INCOMING');
|
|
1437
|
+
this.currentCallState.next('incoming');
|
|
1438
|
+
this.notificationSerivce.showNotification(call);
|
|
1439
|
+
});
|
|
1440
|
+
this.device.on('error', (error) => {
|
|
1441
|
+
console.error('Twilio Device Error:', error);
|
|
1442
|
+
// Reset initialization state on error to allow retry
|
|
1443
|
+
this.tokenInitialized = false;
|
|
1444
|
+
});
|
|
1445
|
+
this.device.on('registered', () => {
|
|
1446
|
+
console.log('Twilio Device registered successfully');
|
|
1447
|
+
});
|
|
1448
|
+
this.device.on('unregistered', () => {
|
|
1449
|
+
console.log('Twilio Device unregistered');
|
|
1450
|
+
this.tokenInitialized = false;
|
|
1486
1451
|
});
|
|
1487
|
-
return this.devicePromise;
|
|
1488
1452
|
}
|
|
1489
1453
|
// onIncomingCall(){
|
|
1490
1454
|
// this.device.on('incoming', (call:any) => {
|
|
@@ -1609,15 +1573,34 @@ class IncomingCallComponent {
|
|
|
1609
1573
|
this.selectedIncomingCallInfo = new EventEmitter();
|
|
1610
1574
|
}
|
|
1611
1575
|
ngOnInit() {
|
|
1576
|
+
// this.twilioService.currentCall.subscribe((call: any) => {
|
|
1577
|
+
// if (call) {
|
|
1578
|
+
// this.twilioCallData = call;
|
|
1579
|
+
// this.notificationSerivce.showNotification(call);
|
|
1580
|
+
// // Handle the call UI
|
|
1581
|
+
// }
|
|
1582
|
+
// });
|
|
1612
1583
|
try {
|
|
1613
|
-
this.twilioService.
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1584
|
+
this.twilioService.currentCall.subscribe(call => {
|
|
1585
|
+
if (call) {
|
|
1586
|
+
this.twilioCallData = call;
|
|
1587
|
+
this.twilioAuthId = call.customParameters.get('twilioAuthId');
|
|
1588
|
+
if (!call.parameters) {
|
|
1589
|
+
call.parameters = {};
|
|
1590
|
+
}
|
|
1620
1591
|
this.sendIPforIncomingCall(this.twilioAuthId, '');
|
|
1592
|
+
call.on('cancel', () => {
|
|
1593
|
+
if (this.incomingCallData && this.incomingCallData.parameters && this.incomingCallData.parameters.CallSid) {
|
|
1594
|
+
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== this.incomingCallData.parameters.CallSid);
|
|
1595
|
+
}
|
|
1596
|
+
this.rejectCallFromList(call);
|
|
1597
|
+
});
|
|
1598
|
+
call.on('disconnect', () => {
|
|
1599
|
+
if (this.incomingCallData && this.incomingCallData.parameters && this.incomingCallData.parameters.CallSid) {
|
|
1600
|
+
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== this.incomingCallData.parameters.CallSid);
|
|
1601
|
+
}
|
|
1602
|
+
this.rejectCallFromList(call);
|
|
1603
|
+
});
|
|
1621
1604
|
}
|
|
1622
1605
|
});
|
|
1623
1606
|
}
|
|
@@ -1640,15 +1623,6 @@ class IncomingCallComponent {
|
|
|
1640
1623
|
}
|
|
1641
1624
|
});
|
|
1642
1625
|
}
|
|
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
1626
|
rejectCallFromList(data) {
|
|
1653
1627
|
if (!data)
|
|
1654
1628
|
return;
|
|
@@ -1663,7 +1637,11 @@ class IncomingCallComponent {
|
|
|
1663
1637
|
this.sendIPforIncomingCall(data.customParameters.get('twilioAuthId'), 'answered');
|
|
1664
1638
|
}
|
|
1665
1639
|
if (this.newIncomingCallsList && data && data.parameters && data.parameters.CallSid) {
|
|
1666
|
-
this.
|
|
1640
|
+
this.newIncomingCallsList = this.newIncomingCallsList.filter((item) => item.parameters && item.parameters.CallSid !== data.parameters.CallSid);
|
|
1641
|
+
this.incomingCallsNewList.emit(this.newIncomingCallsList);
|
|
1642
|
+
if (this.newIncomingCallsList.length == 0) {
|
|
1643
|
+
this.closeIncomingCallDiv.emit({ show: 0, call: data });
|
|
1644
|
+
}
|
|
1667
1645
|
}
|
|
1668
1646
|
}
|
|
1669
1647
|
closeIncomingCallWrapper(val) {
|
|
@@ -2158,9 +2136,6 @@ class CallProgressComponent {
|
|
|
2158
2136
|
incomingCallsNewList(data) {
|
|
2159
2137
|
this.newIncomingCallsList = data;
|
|
2160
2138
|
this.incomingCallsNewInfo.emit(this.newIncomingCallsList);
|
|
2161
|
-
if (!data || data.length === 0) {
|
|
2162
|
-
this.incomingCallDiv = false;
|
|
2163
|
-
}
|
|
2164
2139
|
}
|
|
2165
2140
|
selectedIncomingCallInfo(data) {
|
|
2166
2141
|
this.selectedIncomingCall = data;
|
|
@@ -2503,7 +2478,7 @@ class DialboxComponent {
|
|
|
2503
2478
|
console.log('366---', data);
|
|
2504
2479
|
this.extensionService.getUserInformation(data['twilioAuthId']).subscribe(response => {
|
|
2505
2480
|
incomingCallData['userInfo'] = response;
|
|
2506
|
-
const alreadyExists = this.incomingCallsList.some((call) => call.parameters?.CallSid === incomingCallData.parameters?.CallSid);
|
|
2481
|
+
const alreadyExists = this.incomingCallsList.some((call) => call.parameters?.From === incomingCallData.parameters?.From || call.parameters?.CallSid === incomingCallData.parameters?.CallSid);
|
|
2507
2482
|
if (!alreadyExists) {
|
|
2508
2483
|
this.incomingCallsList.push(incomingCallData);
|
|
2509
2484
|
}
|