@vgroup/dialbox 0.8.24 → 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 = {};
@@ -3775,6 +3777,10 @@ class CallProgressComponent {
3775
3777
  }
3776
3778
  }
3777
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
+ }
3778
3784
  if (!this.currentCallList?.length) {
3779
3785
  this.twilioService.setIncomingMuted(false);
3780
3786
  }
@@ -3783,8 +3789,15 @@ class CallProgressComponent {
3783
3789
  this.twilioService.isConnectingIncomingCallId.next(data?.id);
3784
3790
  this.isIncomingCallBtnDisable = true;
3785
3791
  this.cdr.detectChanges();
3792
+ const acceptStartTime = Date.now();
3786
3793
  let intervalId = setInterval(() => {
3787
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
+ }
3788
3801
  if (callToAccept?.parameters?.CallSid) {
3789
3802
  clearInterval(intervalId);
3790
3803
  const acceptedEntry = {
@@ -3886,17 +3899,18 @@ class CallProgressComponent {
3886
3899
  this.acceptedCallList = this.acceptedCallList.filter(c => c.callSid !== sid);
3887
3900
  this.twilioService.acceptedCallList = this.twilioService.acceptedCallList.filter((c) => c.parameters?.CallSid !== sid);
3888
3901
  this.twilioService.isConnectingIncomingCallId.next('');
3889
- let index = this.currentCallList.findIndex((res) => res.participantId == data.participantId);
3890
- if (index > -1) {
3891
- this.currentCallList.splice(index, 1);
3892
- }
3902
+ this.isConnectingIncomingCallId = '';
3903
+ this.currentCallList = this.currentCallList.filter((res) => res?.id != data?.id);
3893
3904
  this.twilioService.isShowIncomingCall = false;
3894
3905
  this.isConnecting = false;
3895
3906
  this.isIncomingCallBtnDisable = false;
3896
3907
  this.incomeingCallSocketService.pause();
3897
3908
  this.endCallEvent.emit(data);
3898
3909
  this.cdr.detectChanges();
3899
- 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
+ }
3900
3914
  }
3901
3915
  setTimeout(() => {
3902
3916
  this.isUnholdConferenceCall = false;
@@ -3906,9 +3920,9 @@ class CallProgressComponent {
3906
3920
  callToAccept.accept();
3907
3921
  this.cdr.detectChanges();
3908
3922
  }
3909
- 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) {
3910
3924
  clearInterval(intervalId);
3911
- const sid = callToAccept.parameters?.CallSid;
3925
+ const sid = callToAccept?.parameters?.CallSid;
3912
3926
  this.twilioService.isConnectingIncomingCallId.next('');
3913
3927
  this.isConnectingIncomingCallId = '';
3914
3928
  this.acceptedCallList = this.acceptedCallList.filter(c => c.callSid !== sid);
@@ -3934,6 +3948,21 @@ class CallProgressComponent {
3934
3948
  }
3935
3949
  }, 1000);
3936
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
+ }
3937
3966
  async callContact(contact, isUnsavedNumber, options, participantInfo) {
3938
3967
  let phoneNumber = isUnsavedNumber ? contact : contact?.numbersList?.[0]?.number || contact?.phone;
3939
3968
  if (!options?.alreadyNormalized) {
@@ -4653,6 +4682,14 @@ class CallProgressComponent {
4653
4682
  return (hours * 60) + minutes;
4654
4683
  }
4655
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();
4656
4693
  let payload = {
4657
4694
  channelId: environment.channelId,
4658
4695
  recordId: callInfo?.id,