fix(breakout-rooms): Stop previous leave timers if any. (#11842)

* fix(breakout-rooms): Stop previous leave timers if any.

* squash: Rename field.
This commit is contained in:
Дамян Минков 2022-07-12 16:31:43 +03:00 committed by GitHub
parent 155a14b351
commit d981acb94a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 9 deletions

View File

@ -345,9 +345,9 @@ function on_occupant_joined(event)
end
-- Prevent closing all rooms if a participant has joined (see on_occupant_left).
if main_room._data.is_close_all_scheduled then
main_room._data.is_close_all_scheduled = false;
main_room:save();
if main_room.close_timer then
main_room.close_timer:stop();
main_room.close_timer = nil;
end
end
end
@ -397,19 +397,17 @@ function on_occupant_left(event)
end
-- Close the conference if all left for good.
if main_room._data.breakout_rooms_active and not main_room._data.is_close_all_scheduled and not exist_occupants_in_rooms(main_room) then
main_room._data.is_close_all_scheduled = true;
main_room:save(true);
module:add_timer(ROOMS_TTL_IF_ALL_LEFT, function()
if main_room._data.breakout_rooms_active and not main_room.close_timer and not exist_occupants_in_rooms(main_room) then
main_room.close_timer = module:add_timer(ROOMS_TTL_IF_ALL_LEFT, function()
-- we need to look up again the room as till the timer is fired, the room maybe already destroyed/recreated
-- and we will have the old instance
local main_room, main_room_jid = get_main_room(room_jid);
if main_room and main_room._data.is_close_all_scheduled then
if main_room and main_room.close_timer then
module:log('info', 'Closing conference %s as all left for good.', main_room_jid);
main_room:set_persistent(false);
main_room:destroy(nil, 'All occupants left.');
end
end)
end);
end
end