@vgroup/dialbox 0.0.27 → 0.0.28

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.
@@ -115,12 +115,28 @@ class TwilioService {
115
115
  this.callerIdList = new BehaviorSubject([]);
116
116
  this.triggerSMSReload = new BehaviorSubject(false);
117
117
  }
118
- // onIncomingCall(){
119
- // this.device.on('incoming', (call:any) => {
120
- // console.log(call);
121
- // //call.accept();
122
- // });
123
- // }
118
+ onIncomingCall() {
119
+ this.device.on('incoming', (call) => {
120
+ console.log('Incoming call from:', call.parameters['From']);
121
+ // Update the current call subject with the incoming call
122
+ this.currentCall.next(call);
123
+ // Update call state to ringing
124
+ this.currentCallState.next('ringing');
125
+ // Emit a custom event with the call data
126
+ this.dispatchIncomingCallEvent(call);
127
+ });
128
+ }
129
+ dispatchIncomingCallEvent(call) {
130
+ const event = new CustomEvent('incomingCall', {
131
+ detail: {
132
+ call,
133
+ isIncomingCall: true,
134
+ from: call.parameters['From'],
135
+ to: call.parameters['To']
136
+ }
137
+ });
138
+ window.dispatchEvent(event);
139
+ }
124
140
  saveContact(payload) {
125
141
  const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
126
142
  return this.http.post(environment.apiUrl + '/utilities/phonebook/add/contacts/manually', payload, httpOptions);
@@ -1635,14 +1651,19 @@ class CallProgressComponent {
1635
1651
  }
1636
1652
  ngOnChanges(changes) {
1637
1653
  console.log('Call Progress Component ngOnChanges');
1638
- if (changes.callData) {
1639
- console.log('Call Progress Component ngOnChanges callData', changes.callData);
1640
- if (changes.callData.currentValue.isIncomingCall) {
1641
- changes.incomingCallDiv = true;
1654
+ console.log('Call Progress Component ngOnChanges changes', changes);
1655
+ if (changes['callData']) {
1656
+ console.log('Call Progress Component ngOnChanges callData', changes['callData'].currentValue);
1657
+ if (changes['callData'].currentValue?.isIncomingCall) {
1658
+ console.log('Incoming call detected, showing incoming call UI');
1659
+ this.incomingCallDiv = true;
1660
+ this.cdr.detectChanges(); // Trigger change detection
1642
1661
  }
1643
- else {
1644
- //for outgoing call
1645
- this.startCall(changes.callData.currentValue);
1662
+ else if (changes['callData'].currentValue) {
1663
+ // For outgoing call
1664
+ console.log('Outgoing call detected');
1665
+ this.incomingCallDiv = false;
1666
+ this.startCall(changes['callData'].currentValue);
1646
1667
  }
1647
1668
  }
1648
1669
  if (changes.newIncomingCallData) {