@vgroup/dialbox 0.0.54 → 0.0.55
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/dialbox.component.mjs +43 -299
- package/esm2020/lib/service/twilio.service.mjs +47 -42
- package/fesm2015/vgroup-dialbox.mjs +88 -340
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +88 -339
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/dialbox.component.d.ts +6 -5
- package/lib/service/twilio.service.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1316,19 +1316,45 @@ class TwilioService {
|
|
|
1316
1316
|
this.isAvailableNumber = new BehaviorSubject(false);
|
|
1317
1317
|
this.callerIdList = new BehaviorSubject([]);
|
|
1318
1318
|
this.triggerSMSReload = new BehaviorSubject(false);
|
|
1319
|
+
this.isInitialized = false;
|
|
1320
|
+
this.initializationInProgress = false;
|
|
1321
|
+
// Initialize when token is available
|
|
1319
1322
|
this.initializeTwilioDevice();
|
|
1320
1323
|
}
|
|
1321
|
-
|
|
1322
|
-
if (!this.
|
|
1324
|
+
initializeTwilioDevice() {
|
|
1325
|
+
if (this.initializationInProgress || !this.token)
|
|
1323
1326
|
return;
|
|
1324
|
-
|
|
1325
|
-
this.
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1327
|
+
this.initializationInProgress = true;
|
|
1328
|
+
this.extensionService.getIncomingCallToken().subscribe({
|
|
1329
|
+
next: (data) => {
|
|
1330
|
+
if (data === null || data === void 0 ? void 0 : data.token) {
|
|
1331
|
+
this.setupDevice(data.token);
|
|
1332
|
+
this.isInitialized = true;
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
error: (error) => {
|
|
1336
|
+
console.error('Error initializing Twilio:', error);
|
|
1337
|
+
this.initializationInProgress = false;
|
|
1338
|
+
// Retry after delay
|
|
1339
|
+
setTimeout(() => this.initializeTwilioDevice(), 5000);
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
setupDevice(token) {
|
|
1344
|
+
// Clean up existing device if any
|
|
1345
|
+
if (this.device) {
|
|
1346
|
+
this.device.destroy();
|
|
1347
|
+
}
|
|
1348
|
+
this.incomingCallToken = token;
|
|
1349
|
+
localStorage.setItem('in-token', token);
|
|
1350
|
+
this.device = new Device(token, {
|
|
1351
|
+
allowIncomingWhileBusy: true,
|
|
1352
|
+
closeProtection: true
|
|
1353
|
+
});
|
|
1354
|
+
// Set up event listeners
|
|
1330
1355
|
this.device.on('registered', () => {
|
|
1331
|
-
console.log('Twilio Device registered');
|
|
1356
|
+
console.log('Twilio Device registered successfully');
|
|
1357
|
+
this.initializationInProgress = false;
|
|
1332
1358
|
});
|
|
1333
1359
|
this.device.on('incoming', (call) => {
|
|
1334
1360
|
console.log('Incoming call received');
|
|
@@ -1338,40 +1364,19 @@ class TwilioService {
|
|
|
1338
1364
|
});
|
|
1339
1365
|
this.device.on('error', (error) => {
|
|
1340
1366
|
console.error('Twilio Device Error:', error);
|
|
1367
|
+
this.isInitialized = false;
|
|
1368
|
+
this.initializationInProgress = false;
|
|
1369
|
+
// Attempt to reinitialize after error
|
|
1370
|
+
setTimeout(() => this.initializeTwilioDevice(), 5000);
|
|
1341
1371
|
});
|
|
1372
|
+
this.device.on('unregistered', () => {
|
|
1373
|
+
console.log('Twilio Device unregistered');
|
|
1374
|
+
this.isInitialized = false;
|
|
1375
|
+
// Attempt to re-register
|
|
1376
|
+
this.initializeTwilioDevice();
|
|
1377
|
+
});
|
|
1378
|
+
this.device.register();
|
|
1342
1379
|
}
|
|
1343
|
-
initializeTwilioDevice() {
|
|
1344
|
-
if (this.device) {
|
|
1345
|
-
// If device already exists, just re-register
|
|
1346
|
-
this.device.register();
|
|
1347
|
-
return;
|
|
1348
|
-
}
|
|
1349
|
-
if (this.token) {
|
|
1350
|
-
this.extensionService.getIncomingCallToken().subscribe({
|
|
1351
|
-
next: (data) => {
|
|
1352
|
-
this.incomingCallToken = data.token;
|
|
1353
|
-
localStorage.setItem('in-token', data.token);
|
|
1354
|
-
// Destroy existing device if any
|
|
1355
|
-
if (this.device) {
|
|
1356
|
-
this.device.destroy();
|
|
1357
|
-
}
|
|
1358
|
-
this.device = new Device(this.incomingCallToken, {
|
|
1359
|
-
allowIncomingWhileBusy: true,
|
|
1360
|
-
closeProtection: true
|
|
1361
|
-
});
|
|
1362
|
-
this.setupDeviceListeners();
|
|
1363
|
-
this.device.register();
|
|
1364
|
-
},
|
|
1365
|
-
error: (error) => {
|
|
1366
|
-
console.error('Error getting Twilio token:', error);
|
|
1367
|
-
// Add retry logic here if needed
|
|
1368
|
-
}
|
|
1369
|
-
});
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
// onIncomingCall(){
|
|
1373
|
-
// this.device.on('incoming', (call:any) => {
|
|
1374
|
-
// console.log(call);
|
|
1375
1380
|
// //call.accept();
|
|
1376
1381
|
// });
|
|
1377
1382
|
// }
|
|
@@ -2174,6 +2179,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
2174
2179
|
}] } });
|
|
2175
2180
|
|
|
2176
2181
|
class DialboxComponent {
|
|
2182
|
+
set isDialpadHidden(value) {
|
|
2183
|
+
this._isDialpadHidden = value;
|
|
2184
|
+
if (!value && !this.isInitialized) {
|
|
2185
|
+
this.initializeTwilio();
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
get isDialpadHidden() {
|
|
2189
|
+
return this._isDialpadHidden;
|
|
2190
|
+
}
|
|
2191
|
+
initializeTwilio() {
|
|
2192
|
+
if (this.isInitialized || !this.token)
|
|
2193
|
+
return;
|
|
2194
|
+
this.twilioService.initializeTwilioDevice();
|
|
2195
|
+
this.isInitialized = true;
|
|
2196
|
+
// Subscribe to incoming calls
|
|
2197
|
+
const callSub = this.twilioService.currentCall.subscribe(call => {
|
|
2198
|
+
if (call) {
|
|
2199
|
+
this.isCallInProgress = true;
|
|
2200
|
+
this.isDialpadHidden = false; // Show dialpad on incoming call
|
|
2201
|
+
}
|
|
2202
|
+
});
|
|
2203
|
+
this.subscriptions.add(callSub);
|
|
2204
|
+
}
|
|
2177
2205
|
constructor(twilioService, extService, dialog, ipService, extensionService, router) {
|
|
2178
2206
|
this.twilioService = twilioService;
|
|
2179
2207
|
this.extService = extService;
|
|
@@ -2181,7 +2209,7 @@ class DialboxComponent {
|
|
|
2181
2209
|
this.ipService = ipService;
|
|
2182
2210
|
this.extensionService = extensionService;
|
|
2183
2211
|
this.router = router;
|
|
2184
|
-
this.
|
|
2212
|
+
this._isDialpadHidden = true;
|
|
2185
2213
|
this.closeDialpadEvent = new EventEmitter();
|
|
2186
2214
|
this.callInitiated = new EventEmitter();
|
|
2187
2215
|
this.endCallEvent = new EventEmitter();
|
|
@@ -2227,14 +2255,8 @@ class DialboxComponent {
|
|
|
2227
2255
|
this.subscriptions = new Subscription();
|
|
2228
2256
|
this.shakeDedicatedBtn = false;
|
|
2229
2257
|
this.isSmartDialCall = false;
|
|
2230
|
-
this.
|
|
2258
|
+
this.isInitialized = false;
|
|
2231
2259
|
this.isMinimised = false;
|
|
2232
|
-
// Subscribe to incoming calls
|
|
2233
|
-
this.subscriptions.add(this.twilioService.currentCall.subscribe(call => {
|
|
2234
|
-
if (call) {
|
|
2235
|
-
this.handleIncomingCall(call);
|
|
2236
|
-
}
|
|
2237
|
-
}));
|
|
2238
2260
|
}
|
|
2239
2261
|
ngOnInit() {
|
|
2240
2262
|
try {
|
|
@@ -2244,10 +2266,10 @@ class DialboxComponent {
|
|
|
2244
2266
|
this.getUserCallSetting();
|
|
2245
2267
|
// Subscribe to dial number events
|
|
2246
2268
|
const sub1 = this.twilioService.dialNumberFromOtherModule.subscribe((contact) => {
|
|
2247
|
-
if (contact.number) {
|
|
2269
|
+
if (contact === null || contact === void 0 ? void 0 : contact.number) {
|
|
2248
2270
|
this.isSmartDialCall = false;
|
|
2249
2271
|
if (contact.isDialFromHistory) {
|
|
2250
|
-
//
|
|
2272
|
+
// Handle dialing from history page
|
|
2251
2273
|
if (contact.callerId == 'smartDialing') {
|
|
2252
2274
|
this.selectedCallerId = { number: contact.from };
|
|
2253
2275
|
this.isSmartDialCall = true;
|
|
@@ -2361,57 +2383,12 @@ class DialboxComponent {
|
|
|
2361
2383
|
this.registerDragElement();
|
|
2362
2384
|
}
|
|
2363
2385
|
ngOnChanges(changes) {
|
|
2364
|
-
if (changes['isDialpadHidden']) {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
this.getContactList();
|
|
2371
|
-
this.getUserCallSetting();
|
|
2372
|
-
setTimeout(() => {
|
|
2373
|
-
var _a;
|
|
2374
|
-
if ((_a = this.dialInputElement) === null || _a === void 0 ? void 0 : _a.nativeElement) {
|
|
2375
|
-
this.dialInputElement.nativeElement.focus();
|
|
2376
|
-
}
|
|
2377
|
-
}, 0);
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
initializeTwilio() {
|
|
2382
|
-
if (this.isTwilioInitialized || !this.token)
|
|
2383
|
-
return;
|
|
2384
|
-
this.isTwilioInitialized = true;
|
|
2385
|
-
// Clear any existing device first
|
|
2386
|
-
if (this.twilioService.device) {
|
|
2387
|
-
this.twilioService.device.destroy();
|
|
2388
|
-
this.twilioService.device = null;
|
|
2389
|
-
}
|
|
2390
|
-
// Initialize new device
|
|
2391
|
-
this.twilioService.initializeTwilioDevice();
|
|
2392
|
-
// Reset the current call state
|
|
2393
|
-
this.twilioService.currentCall.next(null);
|
|
2394
|
-
this.twilioService.currentCallState.next('none');
|
|
2395
|
-
}
|
|
2396
|
-
handleIncomingCall(call) {
|
|
2397
|
-
try {
|
|
2398
|
-
if (!call)
|
|
2399
|
-
return;
|
|
2400
|
-
this.incomingCallInitiated.emit();
|
|
2401
|
-
this.newIncomingCallData = call;
|
|
2402
|
-
// Add to incoming calls list if not already present
|
|
2403
|
-
const existingCall = this.incomingCallsList.find((c) => c.parameters.CallSid === call.parameters.CallSid);
|
|
2404
|
-
if (!existingCall) {
|
|
2405
|
-
this.incomingCallsList.unshift(call);
|
|
2406
|
-
this.incomingCallsNewInfoEvent.emit(this.incomingCallsList);
|
|
2407
|
-
}
|
|
2408
|
-
// Show the dialpad if it's hidden
|
|
2409
|
-
if (this.isDialpadHidden) {
|
|
2410
|
-
this.isDialpadHidden = false;
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
catch (error) {
|
|
2414
|
-
console.error('Error handling incoming call:', error);
|
|
2386
|
+
if (changes['isDialpadHidden'] && !this.isDialpadHidden) {
|
|
2387
|
+
this.getContactList();
|
|
2388
|
+
this.getUserCallSetting();
|
|
2389
|
+
setTimeout(() => {
|
|
2390
|
+
this.dialInputElement.nativeElement.focus();
|
|
2391
|
+
}, 0);
|
|
2415
2392
|
}
|
|
2416
2393
|
}
|
|
2417
2394
|
registerDragElement() {
|
|
@@ -2621,232 +2598,6 @@ class DialboxComponent {
|
|
|
2621
2598
|
this.endCallEvent.emit();
|
|
2622
2599
|
}
|
|
2623
2600
|
}
|
|
2624
|
-
// async initiateCall() {
|
|
2625
|
-
// try {
|
|
2626
|
-
// console.log('Initiating call with number:', this.dialedNumber);
|
|
2627
|
-
// if (!this.dialedNumber && this.lastDialed) {
|
|
2628
|
-
// console.log('Using last dialed number:', this.lastDialed.number);
|
|
2629
|
-
// this.sanitizedNum = this.lastDialed.number;
|
|
2630
|
-
// }
|
|
2631
|
-
// const isInvalid = await this.isInvalidNumber();
|
|
2632
|
-
// if (isInvalid) {
|
|
2633
|
-
// console.error('Invalid number format');
|
|
2634
|
-
// return false;
|
|
2635
|
-
// }
|
|
2636
|
-
// this.saveLastDialed();
|
|
2637
|
-
// this.isSavedContactDialled();
|
|
2638
|
-
// // Check payment status
|
|
2639
|
-
// this.isPaymentDue = localStorage.getItem('paymentDue') === 'true';
|
|
2640
|
-
// if (this.isPaymentDue) {
|
|
2641
|
-
// console.warn('Payment is due');
|
|
2642
|
-
// swal('Warning', 'Please note that your payment is due. To continue using our services, kindly subscribe to avoid interruptions.');
|
|
2643
|
-
// return false;
|
|
2644
|
-
// }
|
|
2645
|
-
// // Check if dialing own number
|
|
2646
|
-
// if (this.sanitizedNum === localStorage.getItem('twilioNumber')) {
|
|
2647
|
-
// console.error('Attempted to dial own number');
|
|
2648
|
-
// swal('Error', 'You cannot dial your own number');
|
|
2649
|
-
// return false;
|
|
2650
|
-
// }
|
|
2651
|
-
// // Check microphone permissions
|
|
2652
|
-
// const hasPermission = await this.checkMicrophonePermission();
|
|
2653
|
-
// if (!hasPermission) {
|
|
2654
|
-
// console.warn('Microphone permission not granted');
|
|
2655
|
-
// await this.askForMicrophonePermission();
|
|
2656
|
-
// return false;
|
|
2657
|
-
// }
|
|
2658
|
-
// if (!this.selectedCallerId) {
|
|
2659
|
-
// console.error('No caller ID selected');
|
|
2660
|
-
// this.shakeDedicatedBtn = true;
|
|
2661
|
-
// this.showDialAlert('Please select a C2C number to call from');
|
|
2662
|
-
// setTimeout(() => {
|
|
2663
|
-
// this.shakeDedicatedBtn = false;
|
|
2664
|
-
// }, 3000);
|
|
2665
|
-
// return false;
|
|
2666
|
-
// }
|
|
2667
|
-
// console.log('Getting number with country code...');
|
|
2668
|
-
// this.callData.displayNum = '';
|
|
2669
|
-
// try {
|
|
2670
|
-
// await this.getToNumber(this.sanitizedNum);
|
|
2671
|
-
// } catch (error) {
|
|
2672
|
-
// console.error('Error getting number with country code:', error);
|
|
2673
|
-
// this.showDialAlert('Error processing number. Please try again.');
|
|
2674
|
-
// return false;
|
|
2675
|
-
// }
|
|
2676
|
-
// if (this.terminateCall) {
|
|
2677
|
-
// console.log('Call terminated by user');
|
|
2678
|
-
// this.terminateCall = false;
|
|
2679
|
-
// return false;
|
|
2680
|
-
// }
|
|
2681
|
-
// // Prepare call data
|
|
2682
|
-
// this.callData = {
|
|
2683
|
-
// ...this.callData,
|
|
2684
|
-
// phone: this.sanitizedNum,
|
|
2685
|
-
// isIncomingCall: false,
|
|
2686
|
-
// dial: true,
|
|
2687
|
-
// from: this.isSmartDialCall ? this.callData.from : this.selectedCallerId.number,
|
|
2688
|
-
// timestamp: new Date().toISOString()
|
|
2689
|
-
// };
|
|
2690
|
-
// console.log('Initiating call with data:', this.callData);
|
|
2691
|
-
// this.isCallInProgress = true;
|
|
2692
|
-
// this.callInitiated.emit({ ...this.callData });
|
|
2693
|
-
// return true;
|
|
2694
|
-
// } catch (error) {
|
|
2695
|
-
// console.error('Error in initiateCall:', error);
|
|
2696
|
-
// this.showDialAlert('Failed to initiate call. Please try again.');
|
|
2697
|
-
// this.isCallInProgress = false;
|
|
2698
|
-
// return false;
|
|
2699
|
-
// }
|
|
2700
|
-
// //this.clearAllDialed();
|
|
2701
|
-
// // } else {
|
|
2702
|
-
// // swal('Error', 'Trial period is over. Please setup payment method to continue services')
|
|
2703
|
-
// // }
|
|
2704
|
-
// }
|
|
2705
|
-
// async initiateCall() {
|
|
2706
|
-
// if (!this.dialedNumber && this.lastDialed) {
|
|
2707
|
-
// this.sanitizedNum = this.lastDialed.number;
|
|
2708
|
-
// }
|
|
2709
|
-
// const isInvalid = await this.isInvalidNumber();
|
|
2710
|
-
// if (isInvalid) {
|
|
2711
|
-
// return false;
|
|
2712
|
-
// }
|
|
2713
|
-
// this.saveLastDialed();
|
|
2714
|
-
// this.isSavedContactDialled();
|
|
2715
|
-
// //let isCallerIdSet = await this.isCallerIdSet();
|
|
2716
|
-
// this.isPaymentDue = localStorage.getItem('paymentDue') == 'false' ? false : true;
|
|
2717
|
-
// if (this.isPaymentDue) {
|
|
2718
|
-
// swal('Warning', 'Please note that your payment is due, To continue on your services kindly subscribe to use uninterrupted services.');
|
|
2719
|
-
// return;
|
|
2720
|
-
// }
|
|
2721
|
-
// this.isTrialPeriodOver = localStorage.getItem('trialOver') == 'false' ? false : true;
|
|
2722
|
-
// // if (!this.isTrialPeriodOver) {
|
|
2723
|
-
// if (this.sanitizedNum == localStorage.getItem('twilioNumber')) {
|
|
2724
|
-
// swal('Error', 'You can not dial this number');
|
|
2725
|
-
// return;
|
|
2726
|
-
// }
|
|
2727
|
-
// const hasPermission = await this.checkMicrophonePermission();
|
|
2728
|
-
// if (hasPermission) {
|
|
2729
|
-
// if (this.selectedCallerId) {
|
|
2730
|
-
// //clear displayNum if value is binded from previous call
|
|
2731
|
-
// this.callData.displayNum = '';
|
|
2732
|
-
// // get number to be dialled from backend
|
|
2733
|
-
// await this.getToNumber(this.sanitizedNum);
|
|
2734
|
-
// if (this.terminateCall) {
|
|
2735
|
-
// this.terminateCall = false;
|
|
2736
|
-
// return;
|
|
2737
|
-
// }
|
|
2738
|
-
// this.callData.phone = this.sanitizedNum;
|
|
2739
|
-
// this.callData.isIncomingCall = false;
|
|
2740
|
-
// this.callData.dial = true;
|
|
2741
|
-
// if (!this.isSmartDialCall) {
|
|
2742
|
-
// this.callData.from = this.selectedCallerId.number;
|
|
2743
|
-
// }
|
|
2744
|
-
// this.isCallInProgress = true;
|
|
2745
|
-
// this.callData = {
|
|
2746
|
-
// ...this.callData,
|
|
2747
|
-
// phone: this.sanitizedNum,
|
|
2748
|
-
// isIncomingCall: false,
|
|
2749
|
-
// dial: true,
|
|
2750
|
-
// from: this.isSmartDialCall ? this.callData.from : this.selectedCallerId.number,
|
|
2751
|
-
// timestamp: new Date().toISOString()
|
|
2752
|
-
// };
|
|
2753
|
-
// console.log('Initiating call with data:', this.callData);
|
|
2754
|
-
// this.isCallInProgress = true;
|
|
2755
|
-
// this.callInitiated.emit({ ...this.callData });
|
|
2756
|
-
// return true;
|
|
2757
|
-
// } else {
|
|
2758
|
-
// this.shakeDedicatedBtn = true;
|
|
2759
|
-
// this.showDialAlert('Select a C2C number to call');
|
|
2760
|
-
// setTimeout(() => {
|
|
2761
|
-
// this.shakeDedicatedBtn = false;
|
|
2762
|
-
// }, 3000);
|
|
2763
|
-
// return false;
|
|
2764
|
-
// }
|
|
2765
|
-
// //this.callingOpenEvent.emit({ phone: this.dialedNumber });
|
|
2766
|
-
// } else {
|
|
2767
|
-
// await this.askForMicrophonePermission();
|
|
2768
|
-
// }
|
|
2769
|
-
// //this.clearAllDialed();
|
|
2770
|
-
// // } else {
|
|
2771
|
-
// // swal('Error', 'Trial period is over. Please setup payment method to continue services')
|
|
2772
|
-
// // }
|
|
2773
|
-
// }
|
|
2774
|
-
// async initiateCall() {
|
|
2775
|
-
// try{
|
|
2776
|
-
// if (!this.dialedNumber && this.lastDialed) {
|
|
2777
|
-
// this.sanitizedNum = this.lastDialed.number;
|
|
2778
|
-
// }
|
|
2779
|
-
// const isInvalid = await this.isInvalidNumber();
|
|
2780
|
-
// if (isInvalid) {
|
|
2781
|
-
// return false;
|
|
2782
|
-
// }
|
|
2783
|
-
// this.saveLastDialed();
|
|
2784
|
-
// this.isSavedContactDialled();
|
|
2785
|
-
// //let isCallerIdSet = await this.isCallerIdSet();
|
|
2786
|
-
// this.isPaymentDue = localStorage.getItem('paymentDue') == 'false' ? false : true;
|
|
2787
|
-
// if (this.isPaymentDue) {
|
|
2788
|
-
// swal('Warning', 'Please note that your payment is due, To continue on your services kindly subscribe to use uninterrupted services.');
|
|
2789
|
-
// return false;
|
|
2790
|
-
// }
|
|
2791
|
-
// this.isTrialPeriodOver = localStorage.getItem('trialOver') == 'false' ? false : true;
|
|
2792
|
-
// // if (!this.isTrialPeriodOver) {
|
|
2793
|
-
// if (this.sanitizedNum == localStorage.getItem('twilioNumber')) {
|
|
2794
|
-
// swal('Error', 'You can not dial this number');
|
|
2795
|
-
// return false;
|
|
2796
|
-
// }
|
|
2797
|
-
// const hasPermission = await this.checkMicrophonePermission();
|
|
2798
|
-
// if (hasPermission) {
|
|
2799
|
-
// if (this.selectedCallerId) {
|
|
2800
|
-
// //clear displayNum if value is binded from previous call
|
|
2801
|
-
// this.callData.displayNum = '';
|
|
2802
|
-
// // get number to be dialled from backend
|
|
2803
|
-
// await this.getToNumber(this.sanitizedNum);
|
|
2804
|
-
// if (this.terminateCall) {
|
|
2805
|
-
// this.terminateCall = false;
|
|
2806
|
-
// return;
|
|
2807
|
-
// }
|
|
2808
|
-
// this.callData.phone = this.sanitizedNum;
|
|
2809
|
-
// this.callData.isIncomingCall = false;
|
|
2810
|
-
// this.callData.dial = true;
|
|
2811
|
-
// if (!this.isSmartDialCall) {
|
|
2812
|
-
// this.callData.from = this.selectedCallerId.number;
|
|
2813
|
-
// }
|
|
2814
|
-
// this.isCallInProgress = true;
|
|
2815
|
-
// this.callData = {
|
|
2816
|
-
// ...this.callData,
|
|
2817
|
-
// phone: this.sanitizedNum,
|
|
2818
|
-
// isIncomingCall: false,
|
|
2819
|
-
// dial: true,
|
|
2820
|
-
// from: this.isSmartDialCall ? this.callData.from : this.selectedCallerId.number,
|
|
2821
|
-
// timestamp: new Date().toISOString()
|
|
2822
|
-
// };
|
|
2823
|
-
// console.log('Initiating call with data:', this.callData);
|
|
2824
|
-
// this.isCallInProgress = true;
|
|
2825
|
-
// this.callInitiated.emit({ ...this.callData });
|
|
2826
|
-
// return true;
|
|
2827
|
-
// } else {
|
|
2828
|
-
// this.shakeDedicatedBtn = true;
|
|
2829
|
-
// this.showDialAlert('Select a C2C number to call');
|
|
2830
|
-
// setTimeout(() => {
|
|
2831
|
-
// this.shakeDedicatedBtn = false;
|
|
2832
|
-
// }, 3000);
|
|
2833
|
-
// return false;
|
|
2834
|
-
// }
|
|
2835
|
-
// //this.callingOpenEvent.emit({ phone: this.dialedNumber });
|
|
2836
|
-
// } else {
|
|
2837
|
-
// await this.askForMicrophonePermission();
|
|
2838
|
-
// }
|
|
2839
|
-
// //this.clearAllDialed();
|
|
2840
|
-
// // } else {
|
|
2841
|
-
// // swal('Error', 'Trial period is over. Please setup payment method to continue services')
|
|
2842
|
-
// // }
|
|
2843
|
-
// }catch(e){
|
|
2844
|
-
// console.error('Error in initiateCall:', e);
|
|
2845
|
-
// this.showDialAlert('Failed to initiate call. Please try again.');
|
|
2846
|
-
// this.isCallInProgress = false;
|
|
2847
|
-
// return false;
|
|
2848
|
-
// }
|
|
2849
|
-
// }
|
|
2850
2601
|
initiateCall() {
|
|
2851
2602
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2852
2603
|
try {
|
|
@@ -3146,22 +2897,19 @@ class DialboxComponent {
|
|
|
3146
2897
|
}
|
|
3147
2898
|
ngOnDestroy() {
|
|
3148
2899
|
try {
|
|
2900
|
+
console.log('Cleaning up C2cDialpadComponent');
|
|
2901
|
+
// Unsubscribe from all subscriptions
|
|
2902
|
+
if (this.subscriptions) {
|
|
2903
|
+
this.subscriptions.unsubscribe();
|
|
2904
|
+
}
|
|
2905
|
+
// End any active call
|
|
2906
|
+
if (this.isCallInProgress) {
|
|
2907
|
+
this.endCall();
|
|
2908
|
+
}
|
|
3149
2909
|
// Clear any timeouts or intervals if they exist
|
|
3150
2910
|
if (this.toastTimeout) {
|
|
3151
2911
|
clearTimeout(this.toastTimeout);
|
|
3152
2912
|
}
|
|
3153
|
-
// Unsubscribe from all subscriptions
|
|
3154
|
-
this.subscriptions.unsubscribe();
|
|
3155
|
-
// Clean up Twilio device if it exists
|
|
3156
|
-
if (this.twilioService.device) {
|
|
3157
|
-
try {
|
|
3158
|
-
this.twilioService.device.destroy();
|
|
3159
|
-
this.twilioService.device = null;
|
|
3160
|
-
}
|
|
3161
|
-
catch (error) {
|
|
3162
|
-
console.error('Error cleaning up Twilio device:', error);
|
|
3163
|
-
}
|
|
3164
|
-
}
|
|
3165
2913
|
console.log('C2cDialpadComponent cleanup complete');
|
|
3166
2914
|
}
|
|
3167
2915
|
catch (error) {
|