@vgroup/dialbox 0.0.44 → 0.0.45

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.
@@ -3026,9 +3026,40 @@ class DialboxComponent {
3026
3026
  this.newIncomingCallData = call;
3027
3027
  }
3028
3028
  rejectNewIncomingCall(call) {
3029
- call.reject();
3030
- this.newIncomingCalls = this.newIncomingCalls.filter((item) => item.parameters.CallSid !== call.parameters['CallSid']);
3031
- this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters.CallSid !== call.parameters['CallSid']);
3029
+ try {
3030
+ if (!call || typeof call.reject !== 'function') {
3031
+ console.error('Invalid call object provided or missing reject method');
3032
+ return;
3033
+ }
3034
+ // Reject the call
3035
+ call.reject();
3036
+ // Get call SID safely
3037
+ const callSid = call.parameters?.CallSid || call.parameters?.callSid;
3038
+ if (!callSid) {
3039
+ console.warn('No CallSid found for rejected call');
3040
+ return;
3041
+ }
3042
+ // Filter out the rejected call from the lists
3043
+ const filterByCallSid = (item) => {
3044
+ const itemSid = item.parameters?.CallSid || item.parameters?.callSid;
3045
+ return itemSid !== callSid;
3046
+ };
3047
+ // Update call lists
3048
+ if (Array.isArray(this.newIncomingCalls)) {
3049
+ this.newIncomingCalls = this.newIncomingCalls.filter(filterByCallSid);
3050
+ }
3051
+ if (Array.isArray(this.incomingCallsList)) {
3052
+ this.incomingCallsList = this.incomingCallsList.filter(filterByCallSid);
3053
+ }
3054
+ // Reset call state if no more incoming calls
3055
+ if (!this.incomingCallsList || this.incomingCallsList.length === 0) {
3056
+ this.isCallInProgress = false;
3057
+ this.isDialpadHidden = false;
3058
+ }
3059
+ }
3060
+ catch (error) {
3061
+ console.error('Error rejecting incoming call:', error);
3062
+ }
3032
3063
  }
3033
3064
  newIncomingCallInitiated() {
3034
3065
  this.isCallInProgress = true;