@vgroup/dialbox 0.2.5 → 0.2.6

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.
@@ -1774,33 +1774,27 @@ class IncomingCallComponent {
1774
1774
  return false;
1775
1775
  }
1776
1776
  onClickExpand(data) {
1777
- if (this.selectedIncomingCall === data && this.selectedIncomingCall?.isClickExpand) {
1778
- // Collapse if clicking the same expanded item
1779
- const updatedCall = {
1780
- ...this.selectedIncomingCall,
1781
- isClickExpand: false
1782
- };
1777
+ if (this.selectedIncomingCall === data && this.isClickExpand) {
1778
+ this.isClickExpand = false;
1783
1779
  this.selectedIncomingCall = null;
1784
- this.selectedIncomingCallInfo.emit(updatedCall);
1780
+ this.selectedIncomingCallInfo.emit({});
1785
1781
  return;
1786
1782
  }
1787
- // Expand the clicked item
1788
- const updatedCall = {
1789
- ...data,
1790
- isClickExpand: true
1791
- };
1792
- this.selectedIncomingCall = updatedCall;
1793
- // Update the newIncomingCallsList with the updated call
1794
- if (this.newIncomingCallsList?.length) {
1795
- this.newIncomingCallsList = this.newIncomingCallsList.map((call) => call.parameters?.CallSid === updatedCall.parameters?.CallSid
1796
- ? updatedCall
1797
- : { ...call, isClickExpand: false });
1798
- }
1799
- // Emit the updated call to parent
1800
- this.selectedIncomingCallInfo.emit(updatedCall);
1801
- // Fetch user info if needed
1802
- if (!updatedCall.userInfo || updatedCall.userInfo?.status === 201) {
1803
- this.getUserInformation(updatedCall);
1783
+ this.isClickExpand = true;
1784
+ this.selectedIncomingCall = data;
1785
+ if (this.selectedIncomingCall) {
1786
+ this.selectedIncomingCall['isClickExpand'] = true;
1787
+ if (this.newIncomingCallsList && this.newIncomingCallsList.length > 0) {
1788
+ this.newIncomingCallsList.forEach((call) => {
1789
+ if (call !== this.selectedIncomingCall) {
1790
+ call['isClickExpand'] = false;
1791
+ }
1792
+ });
1793
+ }
1794
+ this.selectedIncomingCallInfo.emit(this.selectedIncomingCall);
1795
+ if (!this.selectedIncomingCall.userInfo || this.selectedIncomingCall.userInfo.status == 201) {
1796
+ this.getUserInformation(this.selectedIncomingCall);
1797
+ }
1804
1798
  }
1805
1799
  }
1806
1800
  getUserInformation(incomingCallData) {
@@ -2334,7 +2328,22 @@ class CallProgressComponent {
2334
2328
  codecPreferences: ['opus', 'pcmu'],
2335
2329
  closeProtection: true,
2336
2330
  };
2337
- this.device = new Device(tokenData.token.value, options);
2331
+ // Reuse existing Device if available; otherwise create and register once
2332
+ if (!this.device) {
2333
+ this.device = new Device(tokenData.token.value, options);
2334
+ await this.device.register();
2335
+ }
2336
+ else {
2337
+ // Update token if Device supports it and token changed/rotated
2338
+ try {
2339
+ if (this.device.updateToken) {
2340
+ await this.device.updateToken(tokenData.token.value);
2341
+ }
2342
+ }
2343
+ catch (e) {
2344
+ console.warn('Device updateToken failed, proceeding with existing token', e);
2345
+ }
2346
+ }
2338
2347
  const newCall = await this.device.connect({
2339
2348
  params: {
2340
2349
  From: this.callData.from,
@@ -2669,21 +2678,8 @@ class CallProgressComponent {
2669
2678
  this.newIncomingCallsList = data;
2670
2679
  this.incomingCallsNewInfo.emit(this.newIncomingCallsList);
2671
2680
  }
2672
- selectedIncomingCallInfo(updatedCall) {
2673
- if (!updatedCall || Object.keys(updatedCall).length === 0) {
2674
- this.selectedIncomingCall = null;
2675
- this.cdr.detectChanges();
2676
- return;
2677
- }
2678
- // Update the call in the array if it exists
2679
- if (this.newIncomingCallsList) {
2680
- this.newIncomingCallsList = this.newIncomingCallsList.map((call) => call.parameters?.CallSid === updatedCall.parameters?.CallSid
2681
- ? { ...call, ...updatedCall }
2682
- : { ...call, isClickExpand: false });
2683
- }
2684
- // Update the selected call reference
2685
- this.selectedIncomingCall = updatedCall;
2686
- this.cdr.detectChanges();
2681
+ selectedIncomingCallInfo(data) {
2682
+ this.selectedIncomingCall = data;
2687
2683
  }
2688
2684
  ngOnDestroy() {
2689
2685
  this.callData.dial = false;