@vgroup/dialbox 0.2.61 → 0.2.63

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.
@@ -2123,7 +2123,7 @@ class CallProgressComponent {
2123
2123
  from: callData?.from,
2124
2124
  route: "OUTGOING",
2125
2125
  participantNumber: callData?.phone,
2126
- conferenceId: response?.callauth?.id
2126
+ conferenceId: this.conferenceId
2127
2127
  });
2128
2128
  }, 1000);
2129
2129
  // Poll the status for 30-45 seconds
@@ -2338,187 +2338,85 @@ class CallProgressComponent {
2338
2338
  this.isAddRemoveParticipant = !this.isAddRemoveParticipant;
2339
2339
  this.GetContactsList();
2340
2340
  }
2341
- // async callContact(contact: any) {
2342
- // console.log('Adding contact to call:', contact);
2343
- // // Check if there's an active call
2344
- // if (!this.call || this.call.status() !== 'open') {
2345
- // console.error('No active call to add participant to');
2346
- // return;
2347
- // }
2348
- // // Get the phone number from the contact
2349
- // const phoneNumber = contact.numbersList && contact.numbersList[0]?.number;
2350
- // if (!phoneNumber) {
2351
- // console.error('No phone number found for contact');
2352
- // return;
2353
- // }
2354
- // try {
2355
- // // Put current call on hold
2356
- // if (this.call) {
2357
- // this.heldCall = this.call;
2358
- // this.isCallOnHold = true;
2359
- // this.heldCall.mute(true);
2360
- // console.log('Current call put on hold');
2361
- // }
2362
- // // Close contacts panel
2363
- // this.showContactsPanel = false;
2364
- // // Prepare new call data
2365
- // const newCallData = {
2366
- // phone: phoneNumber,
2367
- // from: this.callData.from,
2368
- // extNum: this.callData.extNum,
2369
- // name: `${contact.firstName} ${contact.middleName || ''} ${contact.lastName || ''}`.trim(),
2370
- // img: contact.img || 'assets/images/user.jpg',
2371
- // displayNum: phoneNumber
2372
- // };
2373
- // // Initiate new call
2374
- // this.showRingAnimation = true;
2375
- // const payload = {
2376
- // channelId: environment.channelId,
2377
- // userId: localStorage.getItem('userId'),
2378
- // to: phoneNumber,
2379
- // scope: 'local',
2380
- // fromNumber: this.callData.from
2381
- // };
2382
- // const response = await this.initiateCall(payload);
2383
- // if (response.status == 200) {
2384
- // const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
2385
- // this.getUserInformation(callAuthId);
2386
- // this.recordCall = recordCall;
2387
- // const tokenData: any = await this.getOutgoingCallToken(callAuthId);
2388
- // // Connect to new call
2389
- // const options: any = {
2390
- // codecPreferences: ['opus', 'pcmu'],
2391
- // closeProtection: true,
2392
- // };
2393
- // // Reuse existing Device if available; otherwise create and register once
2394
- // if (!this.device) {
2395
- // this.device = new Device(tokenData.token.value, options);
2396
- // await this.device.register();
2397
- // } else {
2398
- // // Update token if Device supports it and token changed/rotated
2399
- // try {
2400
- // if ((this.device as any).updateToken) {
2401
- // await (this.device as any).updateToken(tokenData.token.value);
2402
- // }
2403
- // } catch (e) {
2404
- // console.warn('Device updateToken failed, proceeding with existing token', e);
2405
- // }
2406
- // }
2407
- // const newCall = await this.device.connect({
2408
- // params: {
2409
- // From: this.callData.from,
2410
- // To: phoneNumber,
2411
- // Env: environment.abb,
2412
- // Token: tokenData.token.id,
2413
- // Ext: this.callData.extNum
2414
- // },
2415
- // rtcConstraints: { audio: { deviceId: 'default' } },
2416
- // });
2417
- // // Set new call as active
2418
- // this.call = newCall;
2419
- // this.callData = newCallData;
2420
- // // Setup event listeners for new call
2421
- // this.setupEventListeners();
2422
- // // Poll call status
2423
- // this.pollCallStatus(callAuthId);
2424
- // console.log('New call initiated to:', phoneNumber);
2425
- // this.cdr.detectChanges();
2426
- // } else if (response.status == 201) {
2427
- // swal("Error", response.message.join("<br/>"), "error");
2428
- // // Restore held call if new call fails
2429
- // if (this.heldCall) {
2430
- // this.call = this.heldCall;
2431
- // this.heldCall = undefined;
2432
- // this.isCallOnHold = false;
2433
- // this.call.mute(false);
2434
- // }
2435
- // }
2436
- // } catch (error) {
2437
- // console.error('Error adding participant:', error);
2438
- // this.showRingAnimation = false;
2439
- // // Restore held call on error
2440
- // if (this.heldCall) {
2441
- // this.call = this.heldCall;
2442
- // this.heldCall = undefined;
2443
- // this.isCallOnHold = false;
2444
- // this.call.mute(false);
2445
- // }
2446
- // this.handleError(error);
2447
- // }
2448
- // }
2449
- // acceptConcurrentCall(incomingCall: any) {
2450
- // if (!incomingCall) return;
2451
- // // Put current call on hold instead of disconnecting
2452
- // if (this.call) {
2453
- // this.heldCall = this.call;
2454
- // this.isCallOnHold = true;
2455
- // // Mute the held call
2456
- // this.heldCall.mute(true);
2457
- // }
2458
- // incomingCall.accept();
2459
- // this.call = incomingCall;
2460
- // this.callData.phone = incomingCall.parameters['From'];
2461
- // this.callData.name = incomingCall.customParameters?.get('name') || '-';
2462
- // this.callData.img = incomingCall.customParameters?.get('image') || 'assets/images/user.jpg';
2463
- // this.isConcurrentIncoming = false;
2464
- // this.incomingCallDiv = false;
2465
- // this.disbaleEndCallBtn = false;
2466
- // // Reset timer for new call
2467
- // this.stopTimer();
2468
- // this.startTimer();
2469
- // this.cdr.detectChanges();
2470
- // }
2471
2341
  async callContact(contact) {
2472
- console.log("Adding participant:", contact);
2342
+ console.log('Adding participant:', contact);
2343
+ // Check if there's an active call
2473
2344
  if (!this.call || this.call.status() !== 'open') {
2474
2345
  console.error('No active call');
2346
+ swal("Error", "No active call found", "error");
2475
2347
  return;
2476
2348
  }
2349
+ // Get the phone number from the contact
2477
2350
  const phoneNumber = contact?.numbersList?.[0]?.number;
2478
2351
  if (!phoneNumber) {
2479
- console.error("No phone number found");
2352
+ console.error('No phone number found for contact');
2480
2353
  return;
2481
2354
  }
2482
2355
  try {
2483
- // ---- HOLD CURRENT CALL ----
2356
+ // Put current call on hold
2484
2357
  this.heldCall = this.call;
2485
2358
  this.isCallOnHold = true;
2486
2359
  this.heldCall.mute(true);
2360
+ // Close contacts panel and show ring animation
2487
2361
  this.showContactsPanel = false;
2488
2362
  this.showRingAnimation = true;
2489
- if (!this.conferenceId) {
2363
+ // Get the conference ID from the current call or use the stored one
2364
+ const conferenceId = this.conferenceId;
2365
+ if (!conferenceId) {
2490
2366
  console.error("No conferenceId found for active call");
2491
2367
  swal("Error", "Cannot add participant: conference not found", "error");
2492
2368
  this.showRingAnimation = false;
2493
2369
  return;
2494
2370
  }
2495
- // ---- BUILD PAYLOAD ----
2496
- setTimeout(async () => {
2497
- await this.addParticipantToCall({
2498
- from: this.callData?.from,
2499
- route: "OUTGOING",
2500
- participantNumber: this.callData?.phone,
2501
- conferenceId: this.conferenceId
2502
- });
2503
- }, 1000);
2504
- console.log("API Response:", this.conferenceId);
2371
+ // Add participant to the conference
2372
+ await this.addParticipantToCall({
2373
+ from: this.callData?.from,
2374
+ route: "OUTGOING",
2375
+ participantNumber: phoneNumber,
2376
+ conferenceId: conferenceId
2377
+ });
2378
+ console.log("Participant added to conference:", phoneNumber);
2505
2379
  this.showRingAnimation = false;
2506
- swal("Success", "Participant is being added to your call", "success");
2507
- // UI enters conference mode
2380
+ // Update UI to show conference mode
2508
2381
  this.isConference = true;
2382
+ // Show success message
2383
+ swal("Success", "Participant is being added to your call", "success");
2509
2384
  }
2510
- catch (err) {
2511
- console.error("Error adding participant:", err);
2512
- swal("Error", "Failed to add participant", "error");
2385
+ catch (error) {
2386
+ console.error('Error adding participant:', error);
2513
2387
  this.showRingAnimation = false;
2388
+ // Restore held call on error
2514
2389
  if (this.heldCall) {
2515
2390
  this.call = this.heldCall;
2516
2391
  this.heldCall = undefined;
2517
- this.call.mute(false);
2518
2392
  this.isCallOnHold = false;
2393
+ this.call.mute(false);
2519
2394
  }
2395
+ this.handleError(error);
2520
2396
  }
2521
2397
  }
2398
+ // acceptConcurrentCall(incomingCall: any) {
2399
+ // if (!incomingCall) return;
2400
+ // // Put current call on hold instead of disconnecting
2401
+ // if (this.call) {
2402
+ // this.heldCall = this.call;
2403
+ // this.isCallOnHold = true;
2404
+ // // Mute the held call
2405
+ // this.heldCall.mute(true);
2406
+ // }
2407
+ // incomingCall.accept();
2408
+ // this.call = incomingCall;
2409
+ // this.callData.phone = incomingCall.parameters['From'];
2410
+ // this.callData.name = incomingCall.customParameters?.get('name') || '-';
2411
+ // this.callData.img = incomingCall.customParameters?.get('image') || 'assets/images/user.jpg';
2412
+ // this.isConcurrentIncoming = false;
2413
+ // this.incomingCallDiv = false;
2414
+ // this.disbaleEndCallBtn = false;
2415
+ // // Reset timer for new call
2416
+ // this.stopTimer();
2417
+ // this.startTimer();
2418
+ // this.cdr.detectChanges();
2419
+ // }
2522
2420
  acceptConcurrentCall(incomingCall) {
2523
2421
  if (!incomingCall)
2524
2422
  return;