[FIX] website_jitsi: fix participant count update
Bug === When we implemented `website_jitsi` we didn't need to enter a pseudo. Users automatically joined the room. But now we have one more step about entering Jitsi username. During this step the room can become full so we need to check one more time if room reached its full capacity. Correctly use the option `check_full` in `website_event_track_exhibitor`. Do not wait for participant update if the room become full. Task ID-2345894 PR #58516 X-original-commit: 4aae31a7497b9f80b3c3f3d63a22bde646e09f0b
This commit is contained in:
committed by
Thibault Delavallée
parent
b952b92221
commit
bee0b4b6ad
@@ -64,7 +64,8 @@
|
||||
<t t-set="chat_room_id" t-value="meeting_room.chat_room_id.id"/>
|
||||
<t t-set="auto_open" t-value="1"/>
|
||||
<t t-set="attach_to" t-value="'#o_wemeet_jitsi_iframe'"/>
|
||||
<t t-set="check_full" t-value="is_event_manager"/>
|
||||
<t t-set="max_capacity" t-value="meeting_room.room_max_capacity"/>
|
||||
<t t-set="check_full" t-value="int(not is_event_manager)"/>
|
||||
<t t-set="default_username" t-value="default_username"/>
|
||||
<t t-set="jitsi_server_domain" t-value="meeting_room.chat_room_id.jitsi_server_domain"/>
|
||||
</t>
|
||||
|
||||
@@ -73,7 +73,8 @@
|
||||
<t t-set="chat_room_id" t-value="sponsor.chat_room_id.id"/>
|
||||
<t t-set="auto_open" t-value="1"/>
|
||||
<t t-set="attach_to" t-value="'#o_wsponsor_jitsi_iframe'"/>
|
||||
<t t-set="check_full" t-value="option_can_edit"/>
|
||||
<t t-set="max_capacity" t-value="sponsor.room_max_capacity"/>
|
||||
<t t-set="check_full" t-value="int(not option_can_edit)"/>
|
||||
<t t-set="jitsi_server_domain" t-value="sponsor.chat_room_id.jitsi_server_domain"/>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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">
|
||||
<button class="o_wjitsi_room_link btn btn-primary">Join the room</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user