@vgroup/dialbox 0.0.48 → 0.0.49

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.
@@ -1318,54 +1318,26 @@ class TwilioService {
1318
1318
  this.initializeTwilioDevice();
1319
1319
  }
1320
1320
  initializeTwilioDevice() {
1321
- console.log('Initializing Twilio Device...');
1322
- console.log('Token exists:', !!this.token);
1323
- if (!this.token) {
1324
- console.error('No token available for Twilio initialization');
1325
- return;
1326
- }
1327
- this.extensionService.getIncomingCallToken().subscribe({
1328
- next: (data) => {
1329
- console.log('Received Twilio token');
1330
- if (!data || !data.token) {
1331
- console.error('Invalid token received from server');
1332
- return;
1333
- }
1321
+ if (this.token) {
1322
+ this.extensionService.getIncomingCallToken().subscribe((data) => {
1334
1323
  this.incomingCallToken = data.token;
1335
1324
  localStorage.setItem('in-token', data.token);
1336
- try {
1337
- console.log('Creating Twilio Device instance with token:', data.token.substring(0, 10) + '...');
1338
- this.device = new Device(data.token, {
1339
- allowIncomingWhileBusy: true,
1340
- closeProtection: true
1341
- });
1342
- console.log('Registering device...');
1343
- this.device.register();
1344
- this.device.on('registered', () => {
1345
- console.log('Twilio Device registered successfully');
1346
- });
1347
- this.device.on('incoming', (call) => {
1348
- console.log('Incoming call received');
1349
- this.currentCall.next(call);
1350
- this.callType.next('INCOMING');
1351
- this.currentCallState.next('incoming');
1352
- });
1353
- this.device.on('error', (error) => {
1354
- console.error('Twilio Device Error:', error);
1355
- // Attempt to reinitialize after delay
1356
- setTimeout(() => this.initializeTwilioDevice(), 5000);
1357
- });
1358
- }
1359
- catch (error) {
1360
- console.error('Error initializing Twilio Device:', error);
1361
- }
1362
- },
1363
- error: (error) => {
1364
- console.error('Error getting Twilio token:', error);
1365
- // Retry after delay
1366
- setTimeout(() => this.initializeTwilioDevice(), 5000);
1367
- }
1368
- });
1325
+ this.device = new Device(this.incomingCallToken, {
1326
+ allowIncomingWhileBusy: true,
1327
+ // Add any other necessary options
1328
+ });
1329
+ this.device.register();
1330
+ this.device.on('incoming', (call) => {
1331
+ this.currentCall.next(call);
1332
+ this.callType.next('INCOMING');
1333
+ this.currentCallState.next('incoming');
1334
+ });
1335
+ this.device.on('error', (error) => {
1336
+ console.error('Twilio Device Error:', error);
1337
+ // Add error handling and reconnection logic
1338
+ });
1339
+ });
1340
+ }
1369
1341
  }
1370
1342
  // onIncomingCall(){
1371
1343
  // this.device.on('incoming', (call:any) => {
@@ -1573,6 +1545,7 @@ class IncomingCallComponent {
1573
1545
  if (call) {
1574
1546
  this.twilioCallData = call;
1575
1547
  this.twilioAuthId = call.customParameters.get('twilioAuthId');
1548
+ this.newIncomingCallsList.push(call);
1576
1549
  if (!call.parameters) {
1577
1550
  call.parameters = {};
1578
1551
  }