@vgroup/dialbox 0.7.10 → 0.7.11

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.
@@ -1906,6 +1906,8 @@ class CallProgressComponent {
1906
1906
  this.C2ConfoList = {};
1907
1907
  this.lastActiveConferenceId = null;
1908
1908
  this.pendingAutoUnhold = false;
1909
+ this.pendingMuteParticipants = new Set();
1910
+ this.intendedMuteStates = new Map();
1909
1911
  this.isMinimised = false;
1910
1912
  this.showDisconnectModal = false;
1911
1913
  this.call = this.twilioService.call;
@@ -2005,7 +2007,32 @@ class CallProgressComponent {
2005
2007
  this.startTimer((_l = this.currentCall) === null || _l === void 0 ? void 0 : _l.joinedAt);
2006
2008
  }
2007
2009
  else if (index != -1 && !(res === null || res === void 0 ? void 0 : res.isLeft)) {
2008
- this.currentCallList[index] = Object.assign(Object.assign({}, res), { fromName: this.getName(res === null || res === void 0 ? void 0 : res.from) || '', toName: this.getName(res === null || res === void 0 ? void 0 : res.to) || '', img: (res === null || res === void 0 ? void 0 : res.direction) == "incoming-call" ? res === null || res === void 0 ? void 0 : res.toImage : (res === null || res === void 0 ? void 0 : res.fromImage) || (contact === null || contact === void 0 ? void 0 : contact.image) || 'assets/images/user.jpg', isIncomingCall: (res === null || res === void 0 ? void 0 : res.direction) == "incoming-call", isHold: res === null || res === void 0 ? void 0 : res.isHold, isConferenceHold: ((_m = this.newIncomingCallsList) === null || _m === void 0 ? void 0 : _m.length) > 1 ? ourNumberInfo === null || ourNumberInfo === void 0 ? void 0 : ourNumberInfo.isHold : false, isMute: res === null || res === void 0 ? void 0 : res.isMute, isConference: res.isConference ? res.isConference : this.isConference, isAcceptCall: res.direction == "incoming-call" ? this.getStatus(res) : true, dial: true, phone: (res === null || res === void 0 ? void 0 : res.direction) == "incoming-call" ? res === null || res === void 0 ? void 0 : res.from : res === null || res === void 0 ? void 0 : res.to, participantId: res === null || res === void 0 ? void 0 : res.id, conferenceSid: callInfo === null || callInfo === void 0 ? void 0 : callInfo.conferenceSid, name: (res === null || res === void 0 ? void 0 : res.name) || (res === null || res === void 0 ? void 0 : res.fromName) || (res === null || res === void 0 ? void 0 : res.toName), time: this.getTimeDifference((res === null || res === void 0 ? void 0 : res.joinedAt) || new Date().toUTCString()) });
2010
+ //console.log(res);
2011
+ const participantId = res.id;
2012
+ // Check if a mute update is pending for this participant
2013
+ const isMutePending = this.pendingMuteParticipants.has(participantId);
2014
+ const intendedMute = this.intendedMuteStates.get(participantId);
2015
+ console.log("is mute pending =>", isMutePending);
2016
+ console.log("intended mute =>", intendedMute);
2017
+ console.log(participantId);
2018
+ let updatedMute;
2019
+ if (isMutePending) {
2020
+ // If the server already confirmed our change, accept it and clear pending
2021
+ if (res.isMute === intendedMute) {
2022
+ updatedMute = res.isMute;
2023
+ this.pendingMuteParticipants.delete(participantId);
2024
+ this.intendedMuteStates.delete(participantId);
2025
+ }
2026
+ else {
2027
+ // Otherwise, keep the current local value (ignore the stale server state)
2028
+ updatedMute = this.currentCallList[index].isMute;
2029
+ }
2030
+ }
2031
+ else {
2032
+ // No pending mute – trust the server value
2033
+ updatedMute = res.isMute;
2034
+ }
2035
+ this.currentCallList[index] = Object.assign(Object.assign({}, res), { fromName: this.getName(res === null || res === void 0 ? void 0 : res.from) || '', toName: this.getName(res === null || res === void 0 ? void 0 : res.to) || '', img: (res === null || res === void 0 ? void 0 : res.direction) == "incoming-call" ? res === null || res === void 0 ? void 0 : res.toImage : (res === null || res === void 0 ? void 0 : res.fromImage) || (contact === null || contact === void 0 ? void 0 : contact.image) || 'assets/images/user.jpg', isIncomingCall: (res === null || res === void 0 ? void 0 : res.direction) == "incoming-call", isHold: res === null || res === void 0 ? void 0 : res.isHold, isConferenceHold: ((_m = this.newIncomingCallsList) === null || _m === void 0 ? void 0 : _m.length) > 1 ? ourNumberInfo === null || ourNumberInfo === void 0 ? void 0 : ourNumberInfo.isHold : false, isMute: updatedMute, isConference: res.isConference ? res.isConference : this.isConference, isAcceptCall: res.direction == "incoming-call" ? this.getStatus(res) : true, dial: true, phone: (res === null || res === void 0 ? void 0 : res.direction) == "incoming-call" ? res === null || res === void 0 ? void 0 : res.from : res === null || res === void 0 ? void 0 : res.to, participantId: res === null || res === void 0 ? void 0 : res.id, conferenceSid: callInfo === null || callInfo === void 0 ? void 0 : callInfo.conferenceSid, name: (res === null || res === void 0 ? void 0 : res.name) || (res === null || res === void 0 ? void 0 : res.fromName) || (res === null || res === void 0 ? void 0 : res.toName), time: this.getTimeDifference((res === null || res === void 0 ? void 0 : res.joinedAt) || new Date().toUTCString()) });
2009
2036
  }
2010
2037
  }
2011
2038
  else if (!res.isLeft && (res === null || res === void 0 ? void 0 : res.status) != 'no-answer' && (res === null || res === void 0 ? void 0 : res.status) != 'canceled') {
@@ -2320,6 +2347,7 @@ class CallProgressComponent {
2320
2347
  participantListIndo(participants) {
2321
2348
  var _a, _b, _c;
2322
2349
  return __awaiter(this, void 0, void 0, function* () {
2350
+ console.log("participantListIndo");
2323
2351
  if (!(participants === null || participants === void 0 ? void 0 : participants.length)) {
2324
2352
  if ((_a = this.allParticipentList) === null || _a === void 0 ? void 0 : _a.length) {
2325
2353
  this.allParticipentList = [];
@@ -2344,12 +2372,23 @@ class CallProgressComponent {
2344
2372
  anyChange = true;
2345
2373
  return newP;
2346
2374
  }
2375
+ const isMutePending = this.pendingMuteParticipants.has(newP.id);
2376
+ const intendedMute = this.intendedMuteStates.get(newP.id);
2377
+ if (isMutePending && intendedMute !== undefined) {
2378
+ if (newP.isMute === intendedMute) {
2379
+ this.pendingMuteParticipants.delete(newP.id);
2380
+ this.intendedMuteStates.delete(newP.id);
2381
+ }
2382
+ else {
2383
+ newP = Object.assign(Object.assign({}, newP), { isMute: existing.isMute });
2384
+ }
2385
+ }
2347
2386
  const changed = Object.keys(newP).some(k => existing[k] !== newP[k]);
2348
2387
  if (changed) {
2349
2388
  anyChange = true;
2350
2389
  return Object.assign(Object.assign({}, existing), newP);
2351
2390
  }
2352
- return existing; // unchanged — same object reference, *ngFor skips this row
2391
+ return existing;
2353
2392
  });
2354
2393
  if (anyChange) {
2355
2394
  this.selectedConfName = ((_c = this.conferenceCallList.find((res) => (res === null || res === void 0 ? void 0 : res.conferenceId) == this.conferenceCallIDForParticipantList)) === null || _c === void 0 ? void 0 : _c.conferenceName) || '';
@@ -2513,14 +2552,26 @@ class CallProgressComponent {
2513
2552
  }
2514
2553
  onMuteUser(c) {
2515
2554
  return __awaiter(this, void 0, void 0, function* () {
2555
+ const participantId = c.id;
2556
+ const newMuteState = !c.isMute;
2557
+ this.pendingMuteParticipants.add(participantId);
2558
+ this.intendedMuteStates.set(participantId, newMuteState);
2559
+ c.isMute = newMuteState;
2560
+ this.cdr.detectChanges();
2561
+ console.log(c.isMute);
2516
2562
  this.onMuteParticipant({
2517
- participantId: [c.id],
2563
+ participantId: [participantId],
2518
2564
  conferenceId: c === null || c === void 0 ? void 0 : c.conferenceId,
2519
2565
  hold: c.isHold,
2520
- mute: !(c === null || c === void 0 ? void 0 : c.isMute)
2566
+ mute: newMuteState
2521
2567
  });
2522
- c.isMute = !c.isMute;
2523
- this.cdr.detectChanges();
2568
+ //remove pending guard after 5 seconds if no confirmation
2569
+ setTimeout(() => {
2570
+ if (this.pendingMuteParticipants.has(participantId)) {
2571
+ this.pendingMuteParticipants.delete(participantId);
2572
+ this.intendedMuteStates.delete(participantId);
2573
+ }
2574
+ }, 5000);
2524
2575
  });
2525
2576
  }
2526
2577
  onHoldCall(c) {