@vgroup/dialbox 0.0.30 → 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.
@@ -2159,18 +2159,32 @@ class DialboxComponent {
2159
2159
  // this.callData.isIncomingCall = true;
2160
2160
  // }
2161
2161
  if (incomingCallData) {
2162
+ // Create a new call data object to ensure change detection works
2163
+ const newCallData = {
2164
+ ...this.callData,
2165
+ phone: incomingCallData.parameters['From'],
2166
+ name: incomingCallData.customParameters.get('name') || incomingCallData.parameters['From'],
2167
+ img: incomingCallData.customParameters.get('image') || 'assets/images/user.jpg',
2168
+ isIncomingCall: true,
2169
+ callSid: incomingCallData.parameters['CallSid']
2170
+ };
2162
2171
  if (this.isCallInProgress) {
2163
- this.newIncomingCalls.push(incomingCallData);
2172
+ // If there's already a call in progress, add to new incoming calls
2173
+ this.newIncomingCalls.push({
2174
+ ...newCallData,
2175
+ parameters: incomingCallData.parameters,
2176
+ customParameters: incomingCallData.customParameters
2177
+ });
2164
2178
  this.getUserInformation(incomingCallData);
2165
2179
  }
2166
2180
  else {
2181
+ // If no call in progress, handle as primary incoming call
2167
2182
  this.isCallInProgress = true;
2168
2183
  this.isDialpadHidden = false;
2169
- this.callData.phone = incomingCallData.parameters['From'];
2184
+ // Update callData with a new object to trigger change detection
2185
+ this.callData = { ...newCallData };
2186
+ // Get additional user information
2170
2187
  this.getUserInformation(incomingCallData);
2171
- this.callData.name = incomingCallData.customParameters.get('name');
2172
- this.callData.img = incomingCallData.customParameters.get('image') || 'assets/images/user.jpg';
2173
- this.callData.isIncomingCall = true;
2174
2188
  }
2175
2189
  incomingCallData.on('cancel', () => {
2176
2190
  this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== incomingCallData.parameters['CallSid']);
@@ -2196,11 +2210,28 @@ class DialboxComponent {
2196
2210
  getUserInformation(incomingCallData) {
2197
2211
  console.log('getUserInformation', incomingCallData);
2198
2212
  let data = this.fromEntries(Array.from(incomingCallData.customParameters.entries()));
2199
- this.extensionService.getUserInformation(data['twilioAuthId']).subscribe(response => {
2200
- incomingCallData['userInfo'] = response;
2201
- this.incomingCallsList.push(incomingCallData);
2213
+ this.extensionService.getUserInformation(data['twilioAuthId']).subscribe((response) => {
2214
+ try {
2215
+ // Create a new object to trigger change detection
2216
+ const updatedCallData = {
2217
+ ...this.callData,
2218
+ userInfo: response
2219
+ };
2220
+ // Update the call data with a new object to trigger change detection
2221
+ this.callData = { ...updatedCallData };
2222
+ // Add to incoming calls list
2223
+ incomingCallData['userInfo'] = response;
2224
+ this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
2225
+ console.log('Updated callData:', this.callData);
2226
+ }
2227
+ catch (error) {
2228
+ console.error('Error processing user information:', error);
2229
+ }
2202
2230
  }, error => {
2203
- console.error('Error starting recording', error);
2231
+ console.error('Error fetching user information:', error);
2232
+ // Even if there's an error, add the call to the list
2233
+ incomingCallData['userInfo'] = { error: 'Failed to fetch user details' };
2234
+ this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
2204
2235
  });
2205
2236
  }
2206
2237
  fromEntries(entries) {