diff --git a/addons/website_event_meet/views/event_meet_templates_page.xml b/addons/website_event_meet/views/event_meet_templates_page.xml index 7d0a4319cc3..c885c2e7e60 100644 --- a/addons/website_event_meet/views/event_meet_templates_page.xml +++ b/addons/website_event_meet/views/event_meet_templates_page.xml @@ -64,7 +64,8 @@ - + + diff --git a/addons/website_event_track_exhibitor/views/event_exhibitor_templates_page.xml b/addons/website_event_track_exhibitor/views/event_exhibitor_templates_page.xml index bf8b4664329..48a637aa874 100644 --- a/addons/website_event_track_exhibitor/views/event_exhibitor_templates_page.xml +++ b/addons/website_event_track_exhibitor/views/event_exhibitor_templates_page.xml @@ -73,7 +73,8 @@ - + + diff --git a/addons/website_jitsi/static/src/js/chat_room.js b/addons/website_jitsi/static/src/js/chat_room.js index df29af0329e..371438adf8a 100644 --- a/addons/website_jitsi/static/src/js/chat_room.js +++ b/addons/website_jitsi/static/src/js/chat_room.js @@ -44,6 +44,8 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({ this.jitsiServer = this.$el.data('jitsi-server') || 'meet.jit.si'; + this.maxCapacity = parseInt(this.$el.data('max-capacity')) || Infinity; + if (this.autoOpen) { await this._onChatRoomClick(); } @@ -70,11 +72,7 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({ }); if (isChatRoomFull) { - Dialog.alert(this, _t("Sorry, this room is full"), { - title: _t("Warning"), - // reload the page to refresh the participant count - confirm_callback: () => window.location.reload(), - }); + window.location.reload(); return; } } @@ -166,6 +164,10 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({ let timeoutCall = null; const updateParticipantCount = (joined) => { + this.allParticipantIds = Object.keys(jitsiRoom._participants).sort(); + // if we reached the maximum capacity, update immediately the participant count + const timeoutTime = this.allParticipantIds.length >= this.maxCapacity ? 0 : 2000; + // we clear the old timeout to be sure to call it only once each 2 seconds // (so if 2 participants join/leave in this interval, we will perform only // one HTTP request for both). @@ -177,7 +179,7 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({ // count so we avoid to send to many HTTP requests this._updateParticipantCount(this.allParticipantIds.length, joined); } - }, 2000); + }, timeoutTime); }; jitsiRoom.addEventListener('participantJoined', () => updateParticipantCount(true)); @@ -188,6 +190,13 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({ this.participantId = event.id; updateParticipantCount(true); $('.o_wjitsi_chat_room_loading').addClass('d-none'); + + // recheck if the room is not full + if (this.checkFull && this.allParticipantIds.length > this.maxCapacity) { + clearTimeout(timeoutCall); + jitsiRoom.executeCommand('hangup'); + window.location.reload(); + } }); return jitsiRoom; diff --git a/addons/website_jitsi/views/chat_room_templates.xml b/addons/website_jitsi/views/chat_room_templates.xml index 6d9386cf6bb..f733efa64fc 100644 --- a/addons/website_jitsi/views/chat_room_templates.xml +++ b/addons/website_jitsi/views/chat_room_templates.xml @@ -9,6 +9,7 @@ t-att-data-check-full="check_full" t-att-data-attach-to="attach_to" t-att-data-default-username="default_username" + t-att-data-max-capacity="max_capacity" t-att-data-jitsi-server="jitsi_server_domain">