@vgroup/dialbox 0.1.106 → 0.1.108

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.
@@ -2234,9 +2234,102 @@ class CallProgressComponent {
2234
2234
  this.showContactsPanel = !this.showContactsPanel;
2235
2235
  this.GetContactsList();
2236
2236
  }
2237
- callContact(contact) {
2238
- console.log(contact, 'ldldldldlkfjfjj');
2239
- this.extensionService.addParticipant(contact);
2237
+ async callContact(contact) {
2238
+ console.log('Adding contact to call:', contact);
2239
+ // Check if there's an active call
2240
+ if (!this.call || this.call.status() !== 'open') {
2241
+ console.error('No active call to add participant to');
2242
+ return;
2243
+ }
2244
+ // Get the phone number from the contact
2245
+ const phoneNumber = contact.numbersList && contact.numbersList[0]?.number;
2246
+ if (!phoneNumber) {
2247
+ console.error('No phone number found for contact');
2248
+ return;
2249
+ }
2250
+ try {
2251
+ // Put current call on hold
2252
+ if (this.call) {
2253
+ this.heldCall = this.call;
2254
+ this.isCallOnHold = true;
2255
+ this.heldCall.mute(true);
2256
+ console.log('Current call put on hold');
2257
+ }
2258
+ // Close contacts panel
2259
+ this.showContactsPanel = false;
2260
+ // Prepare new call data
2261
+ const newCallData = {
2262
+ phone: phoneNumber,
2263
+ from: this.callData.from,
2264
+ extNum: this.callData.extNum,
2265
+ name: `${contact.firstName} ${contact.middleName || ''} ${contact.lastName || ''}`.trim(),
2266
+ img: contact.img || 'assets/images/user.jpg',
2267
+ displayNum: phoneNumber
2268
+ };
2269
+ // Initiate new call
2270
+ this.showRingAnimation = true;
2271
+ const payload = {
2272
+ channelId: environment.channelId,
2273
+ userId: localStorage.getItem('userId'),
2274
+ to: phoneNumber,
2275
+ scope: 'local',
2276
+ fromNumber: this.callData.from
2277
+ };
2278
+ const response = await this.initiateCall(payload);
2279
+ if (response.status == 200) {
2280
+ const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
2281
+ this.getUserInformation(callAuthId);
2282
+ this.recordCall = recordCall;
2283
+ const tokenData = await this.getOutgoingCallToken(callAuthId);
2284
+ // Connect to new call
2285
+ const options = {
2286
+ codecPreferences: ['opus', 'pcmu'],
2287
+ closeProtection: true,
2288
+ };
2289
+ this.device = new Device(tokenData.token.value, options);
2290
+ const newCall = await this.device.connect({
2291
+ params: {
2292
+ From: this.callData.from,
2293
+ To: phoneNumber,
2294
+ Env: environment.abb,
2295
+ Token: tokenData.token.id,
2296
+ Ext: this.callData.extNum
2297
+ },
2298
+ rtcConstraints: { audio: { deviceId: 'default' } },
2299
+ });
2300
+ // Set new call as active
2301
+ this.call = newCall;
2302
+ this.callData = newCallData;
2303
+ // Setup event listeners for new call
2304
+ this.setupEventListeners();
2305
+ // Poll call status
2306
+ this.pollCallStatus(callAuthId);
2307
+ console.log('New call initiated to:', phoneNumber);
2308
+ this.cdr.detectChanges();
2309
+ }
2310
+ else if (response.status == 201) {
2311
+ swal("Error", response.message.join("<br/>"), "error");
2312
+ // Restore held call if new call fails
2313
+ if (this.heldCall) {
2314
+ this.call = this.heldCall;
2315
+ this.heldCall = undefined;
2316
+ this.isCallOnHold = false;
2317
+ this.call.mute(false);
2318
+ }
2319
+ }
2320
+ }
2321
+ catch (error) {
2322
+ console.error('Error adding participant:', error);
2323
+ this.showRingAnimation = false;
2324
+ // Restore held call on error
2325
+ if (this.heldCall) {
2326
+ this.call = this.heldCall;
2327
+ this.heldCall = undefined;
2328
+ this.isCallOnHold = false;
2329
+ this.call.mute(false);
2330
+ }
2331
+ this.handleError(error);
2332
+ }
2240
2333
  }
2241
2334
  acceptConcurrentCall(incomingCall) {
2242
2335
  if (!incomingCall)