@vgroup/dialbox 0.0.29 → 0.0.31

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.
@@ -115,28 +115,12 @@ class TwilioService {
115
115
  this.callerIdList = new BehaviorSubject([]);
116
116
  this.triggerSMSReload = new BehaviorSubject(false);
117
117
  }
118
- onIncomingCall() {
119
- this.device.on('incoming', (call) => {
120
- console.log('Incoming call from:', call.parameters['From']);
121
- // Update the current call subject with the incoming call
122
- this.currentCall.next(call);
123
- // Update call state to ringing
124
- this.currentCallState.next('ringing');
125
- // Emit a custom event with the call data
126
- this.dispatchIncomingCallEvent(call);
127
- });
128
- }
129
- dispatchIncomingCallEvent(call) {
130
- const event = new CustomEvent('incomingCall', {
131
- detail: {
132
- call,
133
- isIncomingCall: true,
134
- from: call.parameters['From'],
135
- to: call.parameters['To']
136
- }
137
- });
138
- window.dispatchEvent(event);
139
- }
118
+ // onIncomingCall(){
119
+ // this.device.on('incoming', (call:any) => {
120
+ // console.log(call);
121
+ // //call.accept();
122
+ // });
123
+ // }
140
124
  saveContact(payload) {
141
125
  const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
142
126
  return this.http.post(environment.apiUrl + '/utilities/phonebook/add/contacts/manually', payload, httpOptions);
@@ -1587,7 +1571,7 @@ class IncomingCallComponent {
1587
1571
  }
1588
1572
  getUserInformation(incomingCallData) {
1589
1573
  let data = this.fromEntries(Array.from(incomingCallData.customParameters.entries()));
1590
- this.extensionService.getUserInformation(data.twilioAuthId).subscribe(response => {
1574
+ this.extensionService.getUserInformation(data['twilioAuthId']).subscribe(response => {
1591
1575
  setTimeout(() => {
1592
1576
  incomingCallData['userInfo'] = response;
1593
1577
  }, 5000);
@@ -1666,16 +1650,16 @@ class CallProgressComponent {
1666
1650
  this.startCall(changes['callData'].currentValue);
1667
1651
  }
1668
1652
  }
1669
- if (changes.newIncomingCallData) {
1653
+ if (changes['newIncomingCallData']) {
1670
1654
  try {
1671
- if (changes.newIncomingCallData.currentValue) {
1655
+ if (changes['newIncomingCallData'].currentValue) {
1672
1656
  if (this.call && (this.call.status() == 'open')) {
1673
1657
  this.call.disconnect();
1674
- this.call = changes.newIncomingCallData.currentValue;
1658
+ this.call = changes['newIncomingCallData'].currentValue;
1675
1659
  this.call?.accept();
1676
- this.callData.phone = (this.call?.parameters).From;
1677
- this.callData.name = (this.call?.customParameters).get('name');
1678
- this.callData.img = (this.call?.customParameters).get('image') || 'assets/images/user.jpg';
1660
+ this.callData.phone = this.call?.parameters['From'];
1661
+ this.callData.name = this.call?.customParameters.get('name');
1662
+ this.callData.img = this.call?.customParameters.get('image') || 'assets/images/user.jpg';
1679
1663
  this.incomingCallInitiated.emit();
1680
1664
  this.startTimer();
1681
1665
  }
@@ -2176,16 +2160,13 @@ class DialboxComponent {
2176
2160
  // }
2177
2161
  if (incomingCallData) {
2178
2162
  // Create a new call data object to ensure change detection works
2179
- const callSid = incomingCallData.parameters.CallSid;
2180
- const fromNumber = incomingCallData.parameters.From;
2181
2163
  const newCallData = {
2182
- phone: fromNumber,
2183
- displayNum: fromNumber,
2184
- dial: false,
2185
- name: incomingCallData.customParameters.get('name') || fromNumber,
2164
+ ...this.callData,
2165
+ phone: incomingCallData.parameters['From'],
2166
+ name: incomingCallData.customParameters.get('name') || incomingCallData.parameters['From'],
2186
2167
  img: incomingCallData.customParameters.get('image') || 'assets/images/user.jpg',
2187
2168
  isIncomingCall: true,
2188
- callSid: callSid
2169
+ callSid: incomingCallData.parameters['CallSid']
2189
2170
  };
2190
2171
  if (this.isCallInProgress) {
2191
2172
  // If there's already a call in progress, add to new incoming calls
@@ -2206,13 +2187,13 @@ class DialboxComponent {
2206
2187
  this.getUserInformation(incomingCallData);
2207
2188
  }
2208
2189
  incomingCallData.on('cancel', () => {
2209
- this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== incomingCallData.parameters.CallSid);
2190
+ this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== incomingCallData.parameters['CallSid']);
2210
2191
  if (this.incomingCallsList.length == 0) {
2211
2192
  this.isCallInProgress = false;
2212
2193
  }
2213
2194
  });
2214
2195
  incomingCallData.on('disconnect', () => {
2215
- this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== incomingCallData.parameters.CallSid);
2196
+ this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== incomingCallData.parameters['CallSid']);
2216
2197
  if (this.incomingCallsList.length == 0) {
2217
2198
  this.isCallInProgress = false;
2218
2199
  }
@@ -2229,28 +2210,26 @@ class DialboxComponent {
2229
2210
  getUserInformation(incomingCallData) {
2230
2211
  console.log('getUserInformation', incomingCallData);
2231
2212
  let data = this.fromEntries(Array.from(incomingCallData.customParameters.entries()));
2232
- this.extensionService.getUserInformation(data.twilioAuthId).subscribe((response) => {
2213
+ this.extensionService.getUserInformation(data['twilioAuthId']).subscribe((response) => {
2233
2214
  try {
2234
- // Create a safe response object with default values
2235
- const safeResponse = response || {};
2236
- const c2cInfo = safeResponse.c2cInformation || {};
2237
- // Update the call data with user information
2238
- this.callData = {
2215
+ // Create a new object to trigger change detection
2216
+ const updatedCallData = {
2239
2217
  ...this.callData,
2240
- name: c2cInfo.name || this.callData.name,
2241
- displayNum: c2cInfo.number || this.callData.phone,
2242
- userInfo: safeResponse
2218
+ userInfo: response
2243
2219
  };
2220
+ // Update the call data with a new object to trigger change detection
2221
+ this.callData = { ...updatedCallData };
2244
2222
  // Add to incoming calls list
2245
- incomingCallData['userInfo'] = safeResponse;
2223
+ incomingCallData['userInfo'] = response;
2246
2224
  this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
2225
+ console.log('Updated callData:', this.callData);
2247
2226
  }
2248
2227
  catch (error) {
2249
2228
  console.error('Error processing user information:', error);
2250
2229
  }
2251
2230
  }, error => {
2252
2231
  console.error('Error fetching user information:', error);
2253
- // Even if there's an error, we should still add the call to the list
2232
+ // Even if there's an error, add the call to the list
2254
2233
  incomingCallData['userInfo'] = { error: 'Failed to fetch user details' };
2255
2234
  this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
2256
2235
  });
@@ -2265,7 +2244,7 @@ class DialboxComponent {
2265
2244
  this.registerDragElement();
2266
2245
  }
2267
2246
  ngOnChanges(changes) {
2268
- if (changes.isDialpadHidden && !this.isDialpadHidden) {
2247
+ if (changes['isDialpadHidden'] && !this.isDialpadHidden) {
2269
2248
  this.getContactList();
2270
2249
  this.getUserCallSetting();
2271
2250
  setTimeout(() => {
@@ -2984,8 +2963,8 @@ class DialboxComponent {
2984
2963
  }
2985
2964
  rejectNewIncomingCall(call) {
2986
2965
  call.reject();
2987
- this.newIncomingCalls = this.newIncomingCalls.filter((item) => item.parameters.CallSid !== call.parameters.CallSid);
2988
- this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== call.parameters.CallSid);
2966
+ this.newIncomingCalls = this.newIncomingCalls.filter((item) => item.parameters.CallSid !== call.parameters['CallSid']);
2967
+ this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== call.parameters['CallSid']);
2989
2968
  }
2990
2969
  newIncomingCallInitiated() {
2991
2970
  this.isCallInProgress = true;