@vgroup/dialbox 0.0.28 → 0.0.29
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.
|
@@ -2191,18 +2191,31 @@ class DialboxComponent {
|
|
|
2191
2191
|
// this.callData.isIncomingCall = true;
|
|
2192
2192
|
// }
|
|
2193
2193
|
if (incomingCallData) {
|
|
2194
|
+
// Create a new call data object to ensure change detection works
|
|
2195
|
+
const callSid = incomingCallData.parameters.CallSid;
|
|
2196
|
+
const fromNumber = incomingCallData.parameters.From;
|
|
2197
|
+
const newCallData = {
|
|
2198
|
+
phone: fromNumber,
|
|
2199
|
+
displayNum: fromNumber,
|
|
2200
|
+
dial: false,
|
|
2201
|
+
name: incomingCallData.customParameters.get('name') || fromNumber,
|
|
2202
|
+
img: incomingCallData.customParameters.get('image') || 'assets/images/user.jpg',
|
|
2203
|
+
isIncomingCall: true,
|
|
2204
|
+
callSid: callSid
|
|
2205
|
+
};
|
|
2194
2206
|
if (this.isCallInProgress) {
|
|
2195
|
-
|
|
2207
|
+
// If there's already a call in progress, add to new incoming calls
|
|
2208
|
+
this.newIncomingCalls.push(Object.assign(Object.assign({}, newCallData), { parameters: incomingCallData.parameters, customParameters: incomingCallData.customParameters }));
|
|
2196
2209
|
this.getUserInformation(incomingCallData);
|
|
2197
2210
|
}
|
|
2198
2211
|
else {
|
|
2212
|
+
// If no call in progress, handle as primary incoming call
|
|
2199
2213
|
this.isCallInProgress = true;
|
|
2200
2214
|
this.isDialpadHidden = false;
|
|
2201
|
-
|
|
2215
|
+
// Update callData with a new object to trigger change detection
|
|
2216
|
+
this.callData = Object.assign({}, newCallData);
|
|
2217
|
+
// Get additional user information
|
|
2202
2218
|
this.getUserInformation(incomingCallData);
|
|
2203
|
-
this.callData.name = incomingCallData.customParameters.get('name');
|
|
2204
|
-
this.callData.img = incomingCallData.customParameters.get('image') || 'assets/images/user.jpg';
|
|
2205
|
-
this.callData.isIncomingCall = true;
|
|
2206
2219
|
}
|
|
2207
2220
|
incomingCallData.on('cancel', () => {
|
|
2208
2221
|
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== incomingCallData.parameters.CallSid);
|
|
@@ -2228,11 +2241,25 @@ class DialboxComponent {
|
|
|
2228
2241
|
getUserInformation(incomingCallData) {
|
|
2229
2242
|
console.log('getUserInformation', incomingCallData);
|
|
2230
2243
|
let data = this.fromEntries(Array.from(incomingCallData.customParameters.entries()));
|
|
2231
|
-
this.extensionService.getUserInformation(data.twilioAuthId).subscribe(response => {
|
|
2232
|
-
|
|
2233
|
-
|
|
2244
|
+
this.extensionService.getUserInformation(data.twilioAuthId).subscribe((response) => {
|
|
2245
|
+
try {
|
|
2246
|
+
// Create a safe response object with default values
|
|
2247
|
+
const safeResponse = response || {};
|
|
2248
|
+
const c2cInfo = safeResponse.c2cInformation || {};
|
|
2249
|
+
// Update the call data with user information
|
|
2250
|
+
this.callData = Object.assign(Object.assign({}, this.callData), { name: c2cInfo.name || this.callData.name, displayNum: c2cInfo.number || this.callData.phone, userInfo: safeResponse });
|
|
2251
|
+
// Add to incoming calls list
|
|
2252
|
+
incomingCallData['userInfo'] = safeResponse;
|
|
2253
|
+
this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
|
|
2254
|
+
}
|
|
2255
|
+
catch (error) {
|
|
2256
|
+
console.error('Error processing user information:', error);
|
|
2257
|
+
}
|
|
2234
2258
|
}, error => {
|
|
2235
|
-
console.error('Error
|
|
2259
|
+
console.error('Error fetching user information:', error);
|
|
2260
|
+
// Even if there's an error, we should still add the call to the list
|
|
2261
|
+
incomingCallData['userInfo'] = { error: 'Failed to fetch user details' };
|
|
2262
|
+
this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
|
|
2236
2263
|
});
|
|
2237
2264
|
}
|
|
2238
2265
|
fromEntries(entries) {
|