@vgroup/dialbox 0.0.79 → 0.0.81

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.
@@ -1372,8 +1372,7 @@ class TwilioService {
1372
1372
  this.notificationSerivce = notificationSerivce;
1373
1373
  this.openInProgressDialpad = new BehaviorSubject(false);
1374
1374
  this.currentCall = new BehaviorSubject(null);
1375
- this.currentCallState = new BehaviorSubject('none'); // 'incoming', 'in-progress', 'out-progress', 'none'
1376
- this._currentCall = null;
1375
+ this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
1377
1376
  this.callType = new BehaviorSubject('NIL');
1378
1377
  this.isIncomingCallPicked = new BehaviorSubject(false); // for both incoming and outgoing
1379
1378
  this.token = localStorage.getItem('ext_token');
@@ -1401,27 +1400,10 @@ class TwilioService {
1401
1400
  });
1402
1401
  this.device.register();
1403
1402
  this.device.on('incoming', (call) => {
1404
- this._currentCall = call;
1405
1403
  this.currentCall.next(call);
1406
1404
  this.callType.next('INCOMING');
1407
1405
  this.currentCallState.next('incoming');
1408
1406
  this.notificationSerivce.showNotification(call);
1409
- // Set up call event handlers
1410
- call.on('accept', () => {
1411
- this.currentCallState.next('in-progress');
1412
- });
1413
- call.on('disconnect', () => {
1414
- this._currentCall = null;
1415
- this.currentCall.next(null);
1416
- this.currentCallState.next('none');
1417
- this.callType.next('NIL');
1418
- });
1419
- call.on('cancel', () => {
1420
- this._currentCall = null;
1421
- this.currentCall.next(null);
1422
- this.currentCallState.next('none');
1423
- this.callType.next('NIL');
1424
- });
1425
1407
  });
1426
1408
  this.device.on('error', (error) => {
1427
1409
  console.error('Twilio Device Error:', error);
@@ -1521,18 +1503,6 @@ class TwilioService {
1521
1503
  const params = new HttpParams().set('isoCode', isoCode);
1522
1504
  return this.http.get(environment.apiUrl + '/utilities/softphone/check/countryCode/' + dialledNo, httpOptions);
1523
1505
  }
1524
- /**
1525
- * Get the current active call
1526
- */
1527
- getCurrentCall() {
1528
- return this._currentCall;
1529
- }
1530
- /**
1531
- * Check if there's an active call
1532
- */
1533
- hasActiveCall() {
1534
- return this._currentCall !== null;
1535
- }
1536
1506
  }
1537
1507
  TwilioService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, deps: [{ token: i1.HttpClient }, { token: ExtensionService }, { token: NotificationService }], target: i0.ɵɵFactoryTarget.Injectable });
1538
1508
  TwilioService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, providedIn: 'root' });
@@ -2226,8 +2196,10 @@ class DialboxComponent {
2226
2196
  this.isSmartDialCall = false;
2227
2197
  this.isInitialized = false;
2228
2198
  this.isMinimised = false;
2229
- // Always initialize Twilio when component loads to receive calls immediately
2230
- this.initializeTwilio();
2199
+ // Initialize if dialpad is visible by default
2200
+ if (!this.isDialpadHidden) {
2201
+ this.initializeTwilio();
2202
+ }
2231
2203
  }
2232
2204
  initializeTwilio() {
2233
2205
  if (this.isInitialized)
@@ -2238,93 +2210,17 @@ class DialboxComponent {
2238
2210
  return;
2239
2211
  }
2240
2212
  this.isInitialized = true;
2241
- console.log('Initializing Twilio service...');
2242
2213
  // Initialize Twilio service
2243
2214
  this.twilioService.initializeTwilioDevice();
2244
- // Check for any existing call first
2245
- const currentCall = this.twilioService.getCurrentCall();
2246
- if (currentCall) {
2247
- this.handleIncomingCall(currentCall);
2248
- }
2249
2215
  // Subscribe to incoming calls to show dialpad when call comes in
2250
2216
  const callSub = this.twilioService.currentCall.subscribe(call => {
2251
2217
  if (call) {
2252
- console.log('Incoming call received in component:', call);
2253
- this.handleIncomingCall(call);
2254
- }
2255
- });
2256
- // Subscribe to call state changes
2257
- const callStateSub = this.twilioService.currentCallState.subscribe(state => {
2258
- console.log('Call state changed to:', state);
2259
- if (state === 'incoming' || state === 'in-progress') {
2218
+ console.log('Incoming call received:', call);
2260
2219
  this.isCallInProgress = true;
2261
- this._isDialpadHidden = false; // Force show the dialpad for incoming/active calls
2262
- }
2263
- else if (state === 'none') {
2264
- this.isCallInProgress = false;
2220
+ this.isDialpadHidden = false; // Show dialpad on incoming call
2265
2221
  }
2266
2222
  });
2267
2223
  this.subscriptions.add(callSub);
2268
- this.subscriptions.add(callStateSub);
2269
- }
2270
- handleIncomingCall(call) {
2271
- console.log('Handling incoming call:', call);
2272
- // Update call state
2273
- this.isCallInProgress = true;
2274
- // Force show the dialpad by directly setting the private field
2275
- // to bypass any setter logic that might prevent showing it
2276
- this._isDialpadHidden = false;
2277
- // Update call data
2278
- const callerNumber = call.parameters['From'] || 'Unknown';
2279
- const callerName = call.parameters['CallerName'] || 'Unknown Caller';
2280
- this.callData = {
2281
- ...this.callData,
2282
- phone: callerNumber,
2283
- name: callerName,
2284
- img: 'assets/images/user.jpg',
2285
- isIncomingCall: true,
2286
- dial: true
2287
- };
2288
- // Add to incoming calls list if not already present
2289
- const callExists = this.newIncomingCalls.some((c) => c.parameters['CallSid'] === call.parameters['CallSid']);
2290
- if (!callExists) {
2291
- this.newIncomingCalls = [...this.newIncomingCalls, call];
2292
- this.incomingCallsList = [...this.newIncomingCalls];
2293
- }
2294
- // Emit event to notify parent components
2295
- this.incomingCallInitiated.emit();
2296
- // Set up call event handlers if not already set
2297
- if (!call.listenerCount('accept')) {
2298
- call.on('accept', () => {
2299
- console.log('Call accepted:', call.parameters['CallSid']);
2300
- this.isCallInProgress = true;
2301
- this._isDialpadHidden = false; // Ensure dialpad stays open
2302
- });
2303
- }
2304
- if (!call.listenerCount('disconnect')) {
2305
- call.on('disconnect', () => {
2306
- console.log('Call disconnected:', call.parameters['CallSid']);
2307
- this.isCallInProgress = false;
2308
- // Remove from incoming calls list
2309
- this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
2310
- this.newIncomingCalls = this.newIncomingCalls.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
2311
- // If no more calls, reset the state
2312
- if (this.incomingCallsList.length === 0) {
2313
- this.isCallInProgress = false;
2314
- // Don't hide the dialpad if there are no more calls
2315
- // Let the user decide when to close it
2316
- }
2317
- });
2318
- }
2319
- if (!call.listenerCount('cancel')) {
2320
- call.on('cancel', () => {
2321
- console.log('Call cancelled by caller:', call.parameters['CallSid']);
2322
- this.isCallInProgress = false;
2323
- // Remove from incoming calls list
2324
- this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
2325
- this.newIncomingCalls = this.newIncomingCalls.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
2326
- });
2327
- }
2328
2224
  }
2329
2225
  // ngOnChange() {
2330
2226
  // this.initializeTwilio();