@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.
@@ -2342,6 +2342,8 @@ class CallProgressComponent {
2342
2342
  this.conferenceCallList = [];
2343
2343
  this.isIncomingCallBtnDisable = false;
2344
2344
  this.isConnecting = false;
2345
+ // Incoming calls the user already ended – blocks a quick Green click from accepting them again
2346
+ this.rejectedIncomingCallIds = new Set();
2345
2347
  this.isNewAddedCall = false;
2346
2348
  this.deviceNumberList = [];
2347
2349
  this.ourNumberInfo = {};
@@ -3787,6 +3789,10 @@ class CallProgressComponent {
3787
3789
  acceptIncomingCall(data, ourNumberInfo, capturedCall) {
3788
3790
  var _a;
3789
3791
  return __awaiter(this, void 0, void 0, function* () {
3792
+ // Call already ended by the user, or this call is already connecting – ignore the click
3793
+ if (!(data === null || data === void 0 ? void 0 : data.id) || this.rejectedIncomingCallIds.has(data.id) || this.isConnectingIncomingCallId == data.id) {
3794
+ return;
3795
+ }
3790
3796
  if (!((_a = this.currentCallList) === null || _a === void 0 ? void 0 : _a.length)) {
3791
3797
  this.twilioService.setIncomingMuted(false);
3792
3798
  }
@@ -3795,10 +3801,17 @@ class CallProgressComponent {
3795
3801
  this.twilioService.isConnectingIncomingCallId.next(data === null || data === void 0 ? void 0 : data.id);
3796
3802
  this.isIncomingCallBtnDisable = true;
3797
3803
  this.cdr.detectChanges();
3804
+ const acceptStartTime = Date.now();
3798
3805
  let intervalId = setInterval(() => {
3799
- var _a, _b, _c, _d, _e, _f, _g;
3806
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3800
3807
  const callToAccept = this.twilioService.getIncomingCallById(data === null || data === void 0 ? void 0 : data.clientSid);
3801
- if ((_a = callToAccept === null || callToAccept === void 0 ? void 0 : callToAccept.parameters) === null || _a === void 0 ? void 0 : _a.CallSid) {
3808
+ // Twilio call never showed up (ended meanwhile) – don't leave the UI stuck on Connecting
3809
+ if (!((_a = callToAccept === null || callToAccept === void 0 ? void 0 : callToAccept.parameters) === null || _a === void 0 ? void 0 : _a.CallSid) && (this.rejectedIncomingCallIds.has(data.id) || Date.now() - acceptStartTime >= 15000)) {
3810
+ clearInterval(intervalId);
3811
+ this.resetIncomingConnectingState(data);
3812
+ return;
3813
+ }
3814
+ if ((_b = callToAccept === null || callToAccept === void 0 ? void 0 : callToAccept.parameters) === null || _b === void 0 ? void 0 : _b.CallSid) {
3802
3815
  clearInterval(intervalId);
3803
3816
  const acceptedEntry = {
3804
3817
  call: callToAccept,
@@ -3853,7 +3866,7 @@ class CallProgressComponent {
3853
3866
  // this listener. If it did, acceptedCallList would stay non-empty forever, which
3854
3867
  // permanently blocks teardownSpareDevicesIfIdle(), the idle device.disconnectAll()
3855
3868
  // reset in dialbox.component.ts, and twilioService's self-recovery guards.
3856
- const acceptedSid = (_b = callToAccept.parameters) === null || _b === void 0 ? void 0 : _b.CallSid;
3869
+ const acceptedSid = (_c = callToAccept.parameters) === null || _c === void 0 ? void 0 : _c.CallSid;
3857
3870
  callToAccept.on('disconnect', () => {
3858
3871
  if (acceptedSid) {
3859
3872
  this.acceptedCallList = this.acceptedCallList.filter(c => c.callSid !== acceptedSid);
@@ -3902,17 +3915,18 @@ class CallProgressComponent {
3902
3915
  this.acceptedCallList = this.acceptedCallList.filter(c => c.callSid !== sid);
3903
3916
  this.twilioService.acceptedCallList = this.twilioService.acceptedCallList.filter((c) => { var _a; return ((_a = c.parameters) === null || _a === void 0 ? void 0 : _a.CallSid) !== sid; });
3904
3917
  this.twilioService.isConnectingIncomingCallId.next('');
3905
- let index = this.currentCallList.findIndex((res) => res.participantId == data.participantId);
3906
- if (index > -1) {
3907
- this.currentCallList.splice(index, 1);
3908
- }
3918
+ this.isConnectingIncomingCallId = '';
3919
+ this.currentCallList = this.currentCallList.filter((res) => (res === null || res === void 0 ? void 0 : res.id) != (data === null || data === void 0 ? void 0 : data.id));
3909
3920
  this.twilioService.isShowIncomingCall = false;
3910
3921
  this.isConnecting = false;
3911
3922
  this.isIncomingCallBtnDisable = false;
3912
3923
  this.incomeingCallSocketService.pause();
3913
3924
  this.endCallEvent.emit(data);
3914
3925
  this.cdr.detectChanges();
3915
- swal("Error", ((_e = (_d = res === null || res === void 0 ? void 0 : res.message) === null || _d === void 0 ? void 0 : _d.join) === null || _e === void 0 ? void 0 : _e.call(_d, "<br/>")) || 'Internal Server Error', "error");
3926
+ // User already ended this call – the "already answered" error is expected, don't show it
3927
+ if (!this.rejectedIncomingCallIds.has(data === null || data === void 0 ? void 0 : data.id)) {
3928
+ swal("Error", ((_e = (_d = res === null || res === void 0 ? void 0 : res.message) === null || _d === void 0 ? void 0 : _d.join) === null || _e === void 0 ? void 0 : _e.call(_d, "<br/>")) || 'Internal Server Error', "error");
3929
+ }
3916
3930
  }
3917
3931
  setTimeout(() => {
3918
3932
  this.isUnholdConferenceCall = false;
@@ -3922,9 +3936,9 @@ class CallProgressComponent {
3922
3936
  callToAccept.accept();
3923
3937
  this.cdr.detectChanges();
3924
3938
  }
3925
- else if (((_e = (_d = (_c = this.missCallInfo) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.recordId) == (data === null || data === void 0 ? void 0 : data.id) && !((_f = callToAccept.parameters) === null || _f === void 0 ? void 0 : _f.CallSid)) {
3939
+ else if (((_f = (_e = (_d = this.missCallInfo) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.recordId) == (data === null || data === void 0 ? void 0 : data.id) && !((_g = callToAccept === null || callToAccept === void 0 ? void 0 : callToAccept.parameters) === null || _g === void 0 ? void 0 : _g.CallSid)) {
3926
3940
  clearInterval(intervalId);
3927
- const sid = (_g = callToAccept.parameters) === null || _g === void 0 ? void 0 : _g.CallSid;
3941
+ const sid = (_h = callToAccept === null || callToAccept === void 0 ? void 0 : callToAccept.parameters) === null || _h === void 0 ? void 0 : _h.CallSid;
3928
3942
  this.twilioService.isConnectingIncomingCallId.next('');
3929
3943
  this.isConnectingIncomingCallId = '';
3930
3944
  this.acceptedCallList = this.acceptedCallList.filter(c => c.callSid !== sid);
@@ -3952,6 +3966,21 @@ class CallProgressComponent {
3952
3966
  }, 1000);
3953
3967
  });
3954
3968
  }
3969
+ // Accept could not start (Twilio call gone / timed out): drop the Connecting state and go back to idle
3970
+ resetIncomingConnectingState(data) {
3971
+ this.twilioService.isConnectingIncomingCallId.next('');
3972
+ this.isConnectingIncomingCallId = '';
3973
+ this.currentCallList = this.currentCallList.filter((res) => (res === null || res === void 0 ? void 0 : res.id) != (data === null || data === void 0 ? void 0 : data.id));
3974
+ this.twilioService.isShowIncomingCall = false;
3975
+ this.isConnecting = false;
3976
+ this.isIncomingCallBtnDisable = false;
3977
+ this.incomeingCallSocketService.pause();
3978
+ this.endCallEvent.emit(data);
3979
+ this.cdr.detectChanges();
3980
+ setTimeout(() => {
3981
+ this.isUnholdConferenceCall = false;
3982
+ }, 500);
3983
+ }
3955
3984
  callContact(contact, isUnsavedNumber, options, participantInfo) {
3956
3985
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3957
3986
  return __awaiter(this, void 0, void 0, function* () {
@@ -4692,6 +4721,14 @@ class CallProgressComponent {
4692
4721
  return (hours * 60) + minutes;
4693
4722
  }
4694
4723
  onRejectCall(callInfo) {
4724
+ if (!(callInfo === null || callInfo === void 0 ? void 0 : callInfo.id) || this.rejectedIncomingCallIds.has(callInfo.id)) {
4725
+ return;
4726
+ }
4727
+ // Mark ended right away and hide the ringing screen so a quick Green click can't accept it
4728
+ this.rejectedIncomingCallIds.add(callInfo.id);
4729
+ setTimeout(() => this.rejectedIncomingCallIds.delete(callInfo.id), 60000);
4730
+ this.currentCallList = this.currentCallList.filter((res) => (res === null || res === void 0 ? void 0 : res.id) != (callInfo === null || callInfo === void 0 ? void 0 : callInfo.id));
4731
+ this.cdr.detectChanges();
4695
4732
  let payload = {
4696
4733
  channelId: environment.channelId,
4697
4734
  recordId: callInfo === null || callInfo === void 0 ? void 0 : callInfo.id,