From 28b946989d0e38d2186760ed5674983dd3fbbffd Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Tue, 4 Jan 2022 10:07:06 +0000 Subject: [PATCH] [REF] mail: rename isMuted into isSelfMuted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit renames the isMuted variable into isSelfMuted to reflect the user action of self muting, as opposed to the state of being mute, which will be distinct in an upcoming commit. part of task-2720026 closes odoo/odoo#82199 Signed-off-by: Sébastien Theys (seb) --- .../mail/models/mail_channel_rtc_session.py | 2 +- .../rtc_call_participant_card.xml | 2 +- .../rtc_controller/rtc_controller.xml | 10 +++--- .../mail/static/src/models/partner/partner.js | 6 ---- addons/mail/static/src/models/rtc/rtc.js | 32 +++++++++---------- .../rtc_call_participant_card.js | 2 +- .../src/models/rtc_session/rtc_session.js | 10 +++--- addons/mail/tests/test_rtc.py | 18 +++++------ 8 files changed, 38 insertions(+), 44 deletions(-) diff --git a/addons/mail/models/mail_channel_rtc_session.py b/addons/mail/models/mail_channel_rtc_session.py index 4756632dfef..e61277cc676 100644 --- a/addons/mail/models/mail_channel_rtc_session.py +++ b/addons/mail/models/mail_channel_rtc_session.py @@ -104,7 +104,7 @@ class MailRtcSession(models.Model): vals.update({ 'isCameraOn': self.is_camera_on, 'isDeaf': self.is_deaf, - 'isMuted': self.is_muted, + 'isSelfMuted': self.is_muted, 'isScreenSharingOn': self.is_screen_sharing_on, }) if self.guest_id: diff --git a/addons/mail/static/src/components/rtc_call_participant_card/rtc_call_participant_card.xml b/addons/mail/static/src/components/rtc_call_participant_card/rtc_call_participant_card.xml index 1297c93a52e..7b2a91dd121 100644 --- a/addons/mail/static/src/components/rtc_call_participant_card/rtc_call_participant_card.xml +++ b/addons/mail/static/src/components/rtc_call_participant_card/rtc_call_participant_card.xml @@ -49,7 +49,7 @@
- + diff --git a/addons/mail/static/src/components/rtc_controller/rtc_controller.xml b/addons/mail/static/src/components/rtc_controller/rtc_controller.xml index 40c1ddafd17..b0f8cdd2773 100644 --- a/addons/mail/static/src/components/rtc_controller/rtc_controller.xml +++ b/addons/mail/static/src/components/rtc_controller/rtc_controller.xml @@ -6,19 +6,19 @@
- Unmute + Unmute Mute diff --git a/addons/mail/static/src/models/partner/partner.js b/addons/mail/static/src/models/partner/partner.js index d370bd5fe9f..5036dbc9055 100644 --- a/addons/mail/static/src/models/partner/partner.js +++ b/addons/mail/static/src/models/partner/partner.js @@ -37,9 +37,6 @@ registerModel({ if ('id' in data) { data2.id = data.id; } - if ('is_muted' in data) { - data2.isMuted = data.is_muted; - } if ('im_status' in data) { data2.im_status = data.im_status; } @@ -442,9 +439,6 @@ registerModel({ isOnline: attr({ compute: '_computeIsOnline', }), - isMuted: attr({ - default: false, - }), memberThreads: many2many('Thread', { inverse: 'members', }), diff --git a/addons/mail/static/src/models/rtc/rtc.js b/addons/mail/static/src/models/rtc/rtc.js index da5a448392d..4474e08f7f0 100644 --- a/addons/mail/static/src/models/rtc/rtc.js +++ b/addons/mail/static/src/models/rtc/rtc.js @@ -239,8 +239,8 @@ registerModel({ * from the user */ async toggleMicrophone({ requestAudioDevice = true } = {}) { - const shouldMute = this.currentRtcSession.isDeaf || !this.currentRtcSession.isMuted; - this.currentRtcSession.updateAndBroadcast({ isMuted: shouldMute || !this.audioTrack }); + const shouldMute = this.currentRtcSession.isDeaf || !this.currentRtcSession.isSelfMuted; + this.currentRtcSession.updateAndBroadcast({ isSelfMuted: shouldMute || !this.audioTrack }); if (!this.audioTrack && !shouldMute && requestAudioDevice) { // if we don't have an audioTrack, we try to request it again await this.updateLocalAudioTrack(true); @@ -284,7 +284,7 @@ registerModel({ type: 'warning', }); if (this.currentRtcSession) { - this.currentRtcSession.updateAndBroadcast({ isMuted: true }); + this.currentRtcSession.updateAndBroadcast({ isSelfMuted: true }); } return; } @@ -297,11 +297,11 @@ registerModel({ audioTrack.addEventListener('ended', async () => { // this mostly happens when the user retracts microphone permission. await this.async(() => this.updateLocalAudioTrack(false)); - this.currentRtcSession.updateAndBroadcast({ isMuted: true }); + this.currentRtcSession.updateAndBroadcast({ isSelfMuted: true }); await this.async(() => this._updateLocalAudioTrackEnabledState()); }); - this.currentRtcSession.updateAndBroadcast({ isMuted: false }); - audioTrack.enabled = !this.currentRtcSession.isMuted && this.currentRtcSession.isTalking; + this.currentRtcSession.updateAndBroadcast({ isSelfMuted: false }); + audioTrack.enabled = !this.currentRtcSession.isSelfMuted && this.currentRtcSession.isTalking; this.update({ audioTrack }); await this.async(() => this.updateVoiceActivation()); for (const [token, peerConnection] of Object.entries(this._peerConnections)) { @@ -483,7 +483,7 @@ registerModel({ type: 'peerToPeer', payload: { type: 'audio', - state: { isTalking: this.currentRtcSession.isTalking, isMuted: this.currentRtcSession.isMuted }, + state: { isTalking: this.currentRtcSession.isTalking, isSelfMuted: this.currentRtcSession.isSelfMuted }, }, }); } catch (e) { @@ -604,13 +604,13 @@ registerModel({ * @param {Object} param1.state */ _handleTrackChange(rtcSession, { type, state }) { - const { isMuted, isTalking, isSendingVideo, isDeaf } = state; + const { isSelfMuted, isTalking, isSendingVideo, isDeaf } = state; if (type === 'audio') { if (!rtcSession.audioStream) { return; } rtcSession.update({ - isMuted, + isSelfMuted, isTalking, isDeaf, }); @@ -849,7 +849,7 @@ registerModel({ return; } this.currentRtcSession.update({ isTalking }); - if (!this.currentRtcSession.isMuted) { + if (!this.currentRtcSession.isSelfMuted) { await this._updateLocalAudioTrackEnabledState(); } }, @@ -915,7 +915,7 @@ registerModel({ if (track.kind === 'audio') { rtcSession.setAudio({ audioStream: stream, - isMuted: false, + isSelfMuted: false, isTalking: false, }); } @@ -935,15 +935,15 @@ registerModel({ if (!this.audioTrack) { return; } - this.audioTrack.enabled = !this.currentRtcSession.isMuted && this.currentRtcSession.isTalking; + this.audioTrack.enabled = !this.currentRtcSession.isSelfMuted && this.currentRtcSession.isTalking; await this._notifyPeers(Object.keys(this._peerConnections), { event: 'trackChange', type: 'peerToPeer', payload: { type: 'audio', state: { - isTalking: this.currentRtcSession.isTalking && !this.currentRtcSession.isMuted, - isMuted: this.currentRtcSession.isMuted, + isTalking: this.currentRtcSession.isTalking && !this.currentRtcSession.isSelfMuted, + isSelfMuted: this.currentRtcSession.isSelfMuted, isDeaf: this.currentRtcSession.isDeaf, }, }, @@ -1126,7 +1126,7 @@ registerModel({ if (this._pushToTalkTimeoutId) { browser.clearTimeout(this._pushToTalkTimeoutId); } - if (!this.currentRtcSession.isTalking && !this.currentRtcSession.isMuted) { + if (!this.currentRtcSession.isTalking && !this.currentRtcSession.isSelfMuted) { this.messaging.soundEffects.pushToTalk.play({ volume: 0.3 }); } this._setSoundBroadcast(true); @@ -1145,7 +1145,7 @@ registerModel({ if (!this.currentRtcSession.isTalking) { return; } - if (!this.currentRtcSession.isMuted) { + if (!this.currentRtcSession.isSelfMuted) { this.messaging.soundEffects.pushToTalk.play({ volume: 0.3 }); } this._pushToTalkTimeoutId = browser.setTimeout( diff --git a/addons/mail/static/src/models/rtc_call_participant_card/rtc_call_participant_card.js b/addons/mail/static/src/models/rtc_call_participant_card/rtc_call_participant_card.js index 917cba15621..5eadc8f239c 100644 --- a/addons/mail/static/src/models/rtc_call_participant_card/rtc_call_participant_card.js +++ b/addons/mail/static/src/models/rtc_call_participant_card/rtc_call_participant_card.js @@ -94,7 +94,7 @@ registerModel({ * @returns {boolean} */ _computeIsTalking() { - return Boolean(this.rtcSession && this.rtcSession.isTalking && !this.rtcSession.isMuted); + return Boolean(this.rtcSession && this.rtcSession.isTalking && !this.rtcSession.isSelfMuted); }, /** * @private diff --git a/addons/mail/static/src/models/rtc_session/rtc_session.js b/addons/mail/static/src/models/rtc_session/rtc_session.js index 8031750bd84..89b88351120 100644 --- a/addons/mail/static/src/models/rtc_session/rtc_session.js +++ b/addons/mail/static/src/models/rtc_session/rtc_session.js @@ -46,10 +46,10 @@ registerModel({ /** * @param {Object} param0 * @param {MediaStream} param0.audioStream - * @param {boolean} param0.isMuted + * @param {boolean} param0.isSelfMuted * @param {boolean} param0.isTalking */ - async setAudio({ audioStream, isMuted, isTalking }) { + async setAudio({ audioStream, isSelfMuted, isTalking }) { const audioElement = this.audioElement || new window.Audio(); try { audioElement.srcObject = audioStream; @@ -72,7 +72,7 @@ registerModel({ this.update({ audioElement, audioStream, - isMuted, + isSelfMuted, isTalking, }); try { @@ -173,7 +173,7 @@ registerModel({ values: { is_camera_on: this.isCameraOn, is_deaf: this.isDeaf, - is_muted: this.isMuted, + is_muted: this.isSelfMuted, is_screen_sharing_on: this.isScreenSharingOn, }, }, @@ -351,7 +351,7 @@ registerModel({ * means that they cannot send sound regardless of the push to talk or * voice activation (isTalking) state. */ - isMuted: attr({ + isSelfMuted: attr({ default: false, }), /** diff --git a/addons/mail/tests/test_rtc.py b/addons/mail/tests/test_rtc.py index 16a1df69fb8..70a2ed7dc6d 100644 --- a/addons/mail/tests/test_rtc.py +++ b/addons/mail/tests/test_rtc.py @@ -49,7 +49,7 @@ class TestChannelInternals(MailCommon): 'id': channel_partner.rtc_session_ids.id + 1, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': self.user_employee.partner_id.id, @@ -68,7 +68,7 @@ class TestChannelInternals(MailCommon): 'id': channel_partner.rtc_session_ids.id, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': self.user_employee.partner_id.id, @@ -109,7 +109,7 @@ class TestChannelInternals(MailCommon): 'id': last_rtc_session_id + 1, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': self.user_employee.partner_id.id, @@ -164,7 +164,7 @@ class TestChannelInternals(MailCommon): 'id': last_rtc_session_id + 1, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': self.user_employee.partner_id.id, @@ -181,7 +181,7 @@ class TestChannelInternals(MailCommon): 'id': last_rtc_session_id + 1, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': self.user_employee.partner_id.id, @@ -248,7 +248,7 @@ class TestChannelInternals(MailCommon): 'id': channel_partner.rtc_session_ids.id + 1, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': test_user.partner_id.id, @@ -294,7 +294,7 @@ class TestChannelInternals(MailCommon): 'id': channel_partner.rtc_session_ids.id + 2, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'guest': [('insert', { 'id': test_guest.id, @@ -462,7 +462,7 @@ class TestChannelInternals(MailCommon): 'id': channel_partner.rtc_session_ids.id, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': self.user_employee.partner_id.id, @@ -479,7 +479,7 @@ class TestChannelInternals(MailCommon): 'id': channel_partner.rtc_session_ids.id, 'isCameraOn': False, 'isDeaf': False, - 'isMuted': False, + 'isSelfMuted': False, 'isScreenSharingOn': False, 'partner': [('insert', { 'id': self.user_employee.partner_id.id,