@vgroup/dialbox 0.8.23 → 0.8.25

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.
@@ -2322,6 +2322,8 @@ class CallProgressComponent {
2322
2322
  this.conferenceCallList = [];
2323
2323
  this.isIncomingCallBtnDisable = false;
2324
2324
  this.isConnecting = false;
2325
+ // Incoming calls the user already ended – blocks a quick Green click from accepting them again
2326
+ this.rejectedIncomingCallIds = new Set();
2325
2327
  this.isNewAddedCall = false;
2326
2328
  this.deviceNumberList = [];
2327
2329
  this.ourNumberInfo = {};
@@ -3158,6 +3160,8 @@ class CallProgressComponent {
3158
3160
  }).catch((err) => err?.error);
3159
3161
  if (this.isAddParticipantFailed(this.addRes)) {
3160
3162
  this.showAddParticipantError(this.addRes);
3163
+ this.disconnectFailedCall(response?.callauth?.id, isNewConference);
3164
+ return;
3161
3165
  }
3162
3166
  this.isNewCallLoader = false;
3163
3167
  if (isNewConference) {
@@ -3413,6 +3417,32 @@ class CallProgressComponent {
3413
3417
  const message = Array.isArray(res?.message) ? res.message.join('<br/>') : res?.message;
3414
3418
  swal('Error', message || 'Failed to add participant. Please try again.', 'error');
3415
3419
  }
3420
+ // addParticipant failed for a newly started call: close its conference (drops our client leg too).
3421
+ // Only call → back to the dialpad; otherwise the socket feed auto-unholds the previously held conference.
3422
+ disconnectFailedCall(conferenceId, isNewConference) {
3423
+ this.specialCallConferenceIds.delete(conferenceId);
3424
+ if (conferenceId) {
3425
+ this.extensionService.getRemoveParticipants('all', conferenceId).subscribe({
3426
+ error: (err) => console.error('Error closing failed call:', err)
3427
+ });
3428
+ }
3429
+ this.showRingAnimation = false;
3430
+ this.isNewCallLoader = false;
3431
+ this.isNewAddedCall = false;
3432
+ this.showNewCallLoader = false;
3433
+ this.extensionService.isLoadershow.next(false);
3434
+ this.isLoadershown.emit(false);
3435
+ const hasOtherCalls = this.newIncomingCallsList?.some((c) => c?.conferenceId != conferenceId);
3436
+ if (isNewConference && hasOtherCalls) {
3437
+ this.pendingAutoUnhold = true;
3438
+ this.unholdPendingConference();
3439
+ }
3440
+ else {
3441
+ this.call?.disconnect?.();
3442
+ this.endCallEvent.emit();
3443
+ }
3444
+ this.cdr.detectChanges();
3445
+ }
3416
3446
  async initiateCall(payload) {
3417
3447
  return await this.extensionService.initiateCall(payload).toPromise();
3418
3448
  }
@@ -3747,6 +3777,10 @@ class CallProgressComponent {
3747
3777
  }
3748
3778
  }
3749
3779
  async acceptIncomingCall(data, ourNumberInfo, capturedCall) {
3780
+ // Call already ended by the user, or this call is already connecting – ignore the click
3781
+ if (!data?.id || this.rejectedIncomingCallIds.has(data.id) || this.isConnectingIncomingCallId == data.id) {
3782
+ return;
3783
+ }
3750
3784
  if (!this.currentCallList?.length) {
3751
3785
  this.twilioService.setIncomingMuted(false);
3752
3786
  }
@@ -3755,8 +3789,15 @@ class CallProgressComponent {
3755
3789
  this.twilioService.isConnectingIncomingCallId.next(data?.id);
3756
3790
  this.isIncomingCallBtnDisable = true;
3757
3791
  this.cdr.detectChanges();
3792
+ const acceptStartTime = Date.now();
3758
3793
  let intervalId = setInterval(() => {
3759
3794
  const callToAccept = this.twilioService.getIncomingCallById(data?.clientSid);
3795
+ // Twilio call never showed up (ended meanwhile) – don't leave the UI stuck on Connecting
3796
+ if (!callToAccept?.parameters?.CallSid && (this.rejectedIncomingCallIds.has(data.id) || Date.now() - acceptStartTime >= 15000)) {
3797
+ clearInterval(intervalId);
3798
+ this.resetIncomingConnectingState(data);
3799
+ return;
3800
+ }
3760
3801
  if (callToAccept?.parameters?.CallSid) {
3761
3802
  clearInterval(intervalId);
3762
3803
  const acceptedEntry = {
@@ -3858,17 +3899,18 @@ class CallProgressComponent {
3858
3899
  this.acceptedCallList = this.acceptedCallList.filter(c => c.callSid !== sid);
3859
3900
  this.twilioService.acceptedCallList = this.twilioService.acceptedCallList.filter((c) => c.parameters?.CallSid !== sid);
3860
3901
  this.twilioService.isConnectingIncomingCallId.next('');
3861
- let index = this.currentCallList.findIndex((res) => res.participantId == data.participantId);
3862
- if (index > -1) {
3863
- this.currentCallList.splice(index, 1);
3864
- }
3902
+ this.isConnectingIncomingCallId = '';
3903
+ this.currentCallList = this.currentCallList.filter((res) => res?.id != data?.id);
3865
3904
  this.twilioService.isShowIncomingCall = false;
3866
3905
  this.isConnecting = false;
3867
3906
  this.isIncomingCallBtnDisable = false;
3868
3907
  this.incomeingCallSocketService.pause();
3869
3908
  this.endCallEvent.emit(data);
3870
3909
  this.cdr.detectChanges();
3871
- swal("Error", res?.message?.join?.("<br/>") || 'Internal Server Error', "error");
3910
+ // User already ended this call – the "already answered" error is expected, don't show it
3911
+ if (!this.rejectedIncomingCallIds.has(data?.id)) {
3912
+ swal("Error", res?.message?.join?.("<br/>") || 'Internal Server Error', "error");
3913
+ }
3872
3914
  }
3873
3915
  setTimeout(() => {
3874
3916
  this.isUnholdConferenceCall = false;
@@ -3878,9 +3920,9 @@ class CallProgressComponent {
3878
3920
  callToAccept.accept();
3879
3921
  this.cdr.detectChanges();
3880
3922
  }
3881
- else if (this.missCallInfo?.data?.data?.recordId == data?.id && !callToAccept.parameters?.CallSid) {
3923
+ else if (this.missCallInfo?.data?.data?.recordId == data?.id && !callToAccept?.parameters?.CallSid) {
3882
3924
  clearInterval(intervalId);
3883
- const sid = callToAccept.parameters?.CallSid;
3925
+ const sid = callToAccept?.parameters?.CallSid;
3884
3926
  this.twilioService.isConnectingIncomingCallId.next('');
3885
3927
  this.isConnectingIncomingCallId = '';
3886
3928
  this.acceptedCallList = this.acceptedCallList.filter(c => c.callSid !== sid);
@@ -3906,6 +3948,21 @@ class CallProgressComponent {
3906
3948
  }
3907
3949
  }, 1000);
3908
3950
  }
3951
+ // Accept could not start (Twilio call gone / timed out): drop the Connecting state and go back to idle
3952
+ resetIncomingConnectingState(data) {
3953
+ this.twilioService.isConnectingIncomingCallId.next('');
3954
+ this.isConnectingIncomingCallId = '';
3955
+ this.currentCallList = this.currentCallList.filter((res) => res?.id != data?.id);
3956
+ this.twilioService.isShowIncomingCall = false;
3957
+ this.isConnecting = false;
3958
+ this.isIncomingCallBtnDisable = false;
3959
+ this.incomeingCallSocketService.pause();
3960
+ this.endCallEvent.emit(data);
3961
+ this.cdr.detectChanges();
3962
+ setTimeout(() => {
3963
+ this.isUnholdConferenceCall = false;
3964
+ }, 500);
3965
+ }
3909
3966
  async callContact(contact, isUnsavedNumber, options, participantInfo) {
3910
3967
  let phoneNumber = isUnsavedNumber ? contact : contact?.numbersList?.[0]?.number || contact?.phone;
3911
3968
  if (!options?.alreadyNormalized) {
@@ -4625,6 +4682,14 @@ class CallProgressComponent {
4625
4682
  return (hours * 60) + minutes;
4626
4683
  }
4627
4684
  onRejectCall(callInfo) {
4685
+ if (!callInfo?.id || this.rejectedIncomingCallIds.has(callInfo.id)) {
4686
+ return;
4687
+ }
4688
+ // Mark ended right away and hide the ringing screen so a quick Green click can't accept it
4689
+ this.rejectedIncomingCallIds.add(callInfo.id);
4690
+ setTimeout(() => this.rejectedIncomingCallIds.delete(callInfo.id), 60000);
4691
+ this.currentCallList = this.currentCallList.filter((res) => res?.id != callInfo?.id);
4692
+ this.cdr.detectChanges();
4628
4693
  let payload = {
4629
4694
  channelId: environment.channelId,
4630
4695
  recordId: callInfo?.id,