@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.
|
@@ -2175,18 +2175,35 @@ class DialboxComponent {
|
|
|
2175
2175
|
// this.callData.isIncomingCall = true;
|
|
2176
2176
|
// }
|
|
2177
2177
|
if (incomingCallData) {
|
|
2178
|
+
// Create a new call data object to ensure change detection works
|
|
2179
|
+
const callSid = incomingCallData.parameters.CallSid;
|
|
2180
|
+
const fromNumber = incomingCallData.parameters.From;
|
|
2181
|
+
const newCallData = {
|
|
2182
|
+
phone: fromNumber,
|
|
2183
|
+
displayNum: fromNumber,
|
|
2184
|
+
dial: false,
|
|
2185
|
+
name: incomingCallData.customParameters.get('name') || fromNumber,
|
|
2186
|
+
img: incomingCallData.customParameters.get('image') || 'assets/images/user.jpg',
|
|
2187
|
+
isIncomingCall: true,
|
|
2188
|
+
callSid: callSid
|
|
2189
|
+
};
|
|
2178
2190
|
if (this.isCallInProgress) {
|
|
2179
|
-
|
|
2191
|
+
// If there's already a call in progress, add to new incoming calls
|
|
2192
|
+
this.newIncomingCalls.push({
|
|
2193
|
+
...newCallData,
|
|
2194
|
+
parameters: incomingCallData.parameters,
|
|
2195
|
+
customParameters: incomingCallData.customParameters
|
|
2196
|
+
});
|
|
2180
2197
|
this.getUserInformation(incomingCallData);
|
|
2181
2198
|
}
|
|
2182
2199
|
else {
|
|
2200
|
+
// If no call in progress, handle as primary incoming call
|
|
2183
2201
|
this.isCallInProgress = true;
|
|
2184
2202
|
this.isDialpadHidden = false;
|
|
2185
|
-
|
|
2203
|
+
// Update callData with a new object to trigger change detection
|
|
2204
|
+
this.callData = { ...newCallData };
|
|
2205
|
+
// Get additional user information
|
|
2186
2206
|
this.getUserInformation(incomingCallData);
|
|
2187
|
-
this.callData.name = incomingCallData.customParameters.get('name');
|
|
2188
|
-
this.callData.img = incomingCallData.customParameters.get('image') || 'assets/images/user.jpg';
|
|
2189
|
-
this.callData.isIncomingCall = true;
|
|
2190
2207
|
}
|
|
2191
2208
|
incomingCallData.on('cancel', () => {
|
|
2192
2209
|
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== incomingCallData.parameters.CallSid);
|
|
@@ -2212,11 +2229,30 @@ class DialboxComponent {
|
|
|
2212
2229
|
getUserInformation(incomingCallData) {
|
|
2213
2230
|
console.log('getUserInformation', incomingCallData);
|
|
2214
2231
|
let data = this.fromEntries(Array.from(incomingCallData.customParameters.entries()));
|
|
2215
|
-
this.extensionService.getUserInformation(data.twilioAuthId).subscribe(response => {
|
|
2216
|
-
|
|
2217
|
-
|
|
2232
|
+
this.extensionService.getUserInformation(data.twilioAuthId).subscribe((response) => {
|
|
2233
|
+
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 = {
|
|
2239
|
+
...this.callData,
|
|
2240
|
+
name: c2cInfo.name || this.callData.name,
|
|
2241
|
+
displayNum: c2cInfo.number || this.callData.phone,
|
|
2242
|
+
userInfo: safeResponse
|
|
2243
|
+
};
|
|
2244
|
+
// Add to incoming calls list
|
|
2245
|
+
incomingCallData['userInfo'] = safeResponse;
|
|
2246
|
+
this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
|
|
2247
|
+
}
|
|
2248
|
+
catch (error) {
|
|
2249
|
+
console.error('Error processing user information:', error);
|
|
2250
|
+
}
|
|
2218
2251
|
}, error => {
|
|
2219
|
-
console.error('Error
|
|
2252
|
+
console.error('Error fetching user information:', error);
|
|
2253
|
+
// Even if there's an error, we should still add the call to the list
|
|
2254
|
+
incomingCallData['userInfo'] = { error: 'Failed to fetch user details' };
|
|
2255
|
+
this.incomingCallsList = [...this.incomingCallsList, incomingCallData];
|
|
2220
2256
|
});
|
|
2221
2257
|
}
|
|
2222
2258
|
fromEntries(entries) {
|