From 307cec490a2206f4b68b7d77d2dfa7d06d9485ae Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Fri, 10 Jun 2022 04:53:12 +0000 Subject: [PATCH] [REF] mail: move DOM function to view model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the addition of the CallParticipantVideoView model, it makes more sense to have this view(DOM) related function in it. closes odoo/odoo#93260 Signed-off-by: Alexandre Kühn (aku) --- .../call_participant_video.xml | 2 +- .../src/models/call_participant_video_view.js | 17 +++++++++++++++++ addons/mail/static/src/models/rtc_session.js | 17 ----------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/addons/mail/static/src/components/call_participant_video/call_participant_video.xml b/addons/mail/static/src/components/call_participant_video/call_participant_video.xml index fabac5088ae..86be94b7172 100644 --- a/addons/mail/static/src/components/call_participant_video/call_participant_video.xml +++ b/addons/mail/static/src/components/call_participant_video/call_participant_video.xml @@ -8,7 +8,7 @@ playsinline="true" autoplay="true" muted="true" - t-on-loadedmetadata="callParticipantVideoView.rtcSession.onVideoLoadedMetaData" + t-on-loadedmetadata="callParticipantVideoView.onVideoLoadedMetaData" t-ref="root" /> diff --git a/addons/mail/static/src/models/call_participant_video_view.js b/addons/mail/static/src/models/call_participant_video_view.js index 8909bad2c57..de552158e3e 100644 --- a/addons/mail/static/src/models/call_participant_video_view.js +++ b/addons/mail/static/src/models/call_participant_video_view.js @@ -8,6 +8,23 @@ registerModel({ name: 'CallParticipantVideoView', identifyingFields: ['callParticipantCardOwner'], recordMethods: { + /** + * Plays the video as some browsers may not support or block autoplay. + * + * @param {Event} ev + */ + async onVideoLoadedMetaData(ev) { + try { + await ev.target.play(); + } catch (error) { + if (typeof error === 'object' && error.name === 'NotAllowedError') { + // Ignored as some browsers may reject play() calls that do not + // originate from a user input. + return; + } + throw error; + } + }, /** * @private * @returns {FieldCommand} diff --git a/addons/mail/static/src/models/rtc_session.js b/addons/mail/static/src/models/rtc_session.js index e7b311b57e5..a9d770a7e9d 100644 --- a/addons/mail/static/src/models/rtc_session.js +++ b/addons/mail/static/src/models/rtc_session.js @@ -13,23 +13,6 @@ registerModel({ }, }, recordMethods: { - /** - * Plays the video as some browsers may not support or block autoplay. - * - * @param {Event} ev - */ - async onVideoLoadedMetaData(ev) { - try { - await ev.target.play(); - } catch (error) { - if (typeof error === 'object' && error.name === 'NotAllowedError') { - // Ignored as some browsers may reject play() calls that do not - // originate from a user input. - return; - } - throw error; - } - }, /** * restores the session to its default values */