instead of detecting user remove, track breakout end => close tab

This commit is contained in:
Anton Georgiev 2017-02-09 16:28:41 -05:00
parent 577809b5a3
commit ad80d31b9a

View File

@ -48,6 +48,7 @@ function subscribeToCollections(cb) {
observeUserKick();
return Promise.all(subscribeForData())
.then(() => {
observeBreakoutEnd();
if (cb) {
return cb();
}
@ -68,17 +69,22 @@ const wasKickedDep = new Tracker.Dependency;
function observeUserKick() {
Users.find().observe({
removed(old) {
const isMeetingBreakout = Breakouts.find(b => b.breakoutMeetingId === meetingId);
if (old.userId === Auth.userID) {
Auth.clearCredentials(() => {
wasKicked = true;
wasKickedDep.changed();
});
}
},
});
}
if (!Breakouts.length || isMeetingBreakout) {
window.close();
}
function observeBreakoutEnd() {
Breakouts.find().observe({
removed(old) {
if (old.breakoutMeetingId === Auth.meetingID) {
// The breakout room expired. Closing the browser tab to return to the main room
window.close();
}
},
});