diff --git a/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js b/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js index 9869ea917c4..14c5445b01e 100644 --- a/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js +++ b/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js @@ -338,5 +338,33 @@ QUnit.test('invite button should be present on livechat', async function (assert ); }); +QUnit.test('call buttons should not be present on livechat', async function (assert) { + assert.expect(1); + + const pyEnv = await startServer(); + const mailChannelId1 = pyEnv['mail.channel'].create( + { + anonymous_name: "Visitor 11", + channel_type: 'livechat', + livechat_operator_id: pyEnv.currentPartnerId, + channel_partner_ids: [pyEnv.currentPartnerId, pyEnv.publicPartnerId], + }, + ); + await start({ + autoOpenDiscuss: true, + discuss: { + params: { + default_active_id: `mail.channel_${mailChannelId1}`, + }, + }, + hasDiscuss: true, + }); + assert.containsNone( + document.body, + '.o_ThreadViewTopbar_callButton', + "Call buttons should not be visible in top bar when livechat is active thread" + ); +}); + }); }); diff --git a/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml b/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml index 012a7fe9d84..a065e29123c 100644 --- a/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml +++ b/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml @@ -49,7 +49,7 @@ - + diff --git a/addons/mail/static/src/models/thread.js b/addons/mail/static/src/models/thread.js index a7e2206087e..ceda60e6ecd 100644 --- a/addons/mail/static/src/models/thread.js +++ b/addons/mail/static/src/models/thread.js @@ -1264,6 +1264,13 @@ registerModel({ _computeFutureActivities() { return replace(this.activities.filter(activity => activity.state === 'planned')); }, + /** + * @private + * @returns {boolean} + */ + _computeHasCallFeature() { + return ['channel', 'chat', 'group'].includes(this.channel_type); + }, /** * @private * @returns {boolean} @@ -1976,6 +1983,12 @@ registerModel({ hasActivities: attr({ default: false, }), + /** + * Determines whether the RTC call feature should be displayed. + */ + hasCallFeature: attr({ + compute: '_computeHasCallFeature', + }), /** * States whether this thread should has the invite feature. Only makes * sense for channels.