polish breakout room code html5

This commit is contained in:
Gabriel Carvalho de Campes 2016-11-14 14:12:54 -02:00
parent 3f53620416
commit eb3705321f
7 changed files with 75 additions and 26 deletions

View File

@ -1,5 +1,10 @@
import clearBreakouts from '../modifiers/clearBreakouts';
import { check } from 'meteor/check';
export default function breakoutClosed({ payload }) {
const meetingId = payload.meetingId;
check(meetingId, String);
return clearBreakouts(payload.meetingId);
}

View File

@ -1,5 +1,6 @@
import Breakouts from '/imports/api/breakouts';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
import { XMLHttpRequest } from 'xmlhttprequest';
import xml2js from 'xml2js';
@ -19,10 +20,11 @@ export default function breakoutJoinURL({ payload }) {
const REDIS_CONFIG = Meteor.settings.redis;
const {
meetingId,
joinURL,
} = payload;
check(joinURL, String);
const urlParams = getUrlParams(joinURL);
const selector = {

View File

@ -1,7 +1,12 @@
import Breakouts from '/imports/api/breakouts';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
export default function ({ payload }) {
const meetingId = payload.meetingId;
check(meetingId, String);
const selector = {
breakoutMeetingId: payload.meetingId,
};

View File

@ -1,7 +1,12 @@
import Breakouts from '/imports/api/breakouts';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
export default function({ payload }) {
const breakoutMeetingId = payload.breakoutMeetingId;
check(breakoutMeetingId, String);
const selector = {
breakoutMeetingId: payload.breakoutMeetingId,
};

View File

@ -1,8 +1,16 @@
import Breakouts from '/imports/api/breakouts';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
export default function updateTimeRemaining({ payload }) {
console.log('updateTimeRemaining', payload);
const {
meetingId,
timeRemaining,
} = payload;
check(meetingId, String);
check(timeRemaining, Number);
const selector = {
parentMeetingId: payload.meetingId,
};

View File

@ -1,15 +1,11 @@
import Breakouts from '/imports/api/breakouts';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import { isAllowedTo } from '/imports/startup/server/userPermissions';
Meteor.publish('breakouts', (credentials) => {
Logger.info(`PUBLISHIIIIIIING breakouts for ${credentials.meetingId}`);
return Breakouts.find({
Meteor.publish('breakouts', credentials =>
Breakouts.find({
$or: [
{ parentMeetingId: credentials.meetingId },
{ breakoutMeetingId: credentials.meetingId },
],
});
});
})
);

View File

@ -48,6 +48,21 @@ const intlMessages = defineMessages({
defaultMessage: 'Disconnected. Trying to reconnect in {seconds} seconds...',
description: 'Message when the client is trying to reconnect to the server',
},
breakoutTimeRemaining: {
id: 'app.breakoutTimeRemainingMessage',
defaultMessage: 'Breakout Room time remaining: {time}',
description: 'Message that tells how much time is remaining for the breakout room',
},
breakoutWillClose: {
id: 'app.breakoutWillCloseMessage',
defaultMessage: 'Time ended. Breakout Room will close soon',
description: 'Message that tells time has ended and breakout will close',
},
calculatingBreakoutTimeRemaining: {
id: 'app.calculatingBreakoutTimeRemaining',
defaultMessage: 'Calculating remaining time...',
description: 'Message that tells that the remaining time is being calculated',
},
});
class NotificationsBarContainer extends Component {
@ -70,6 +85,7 @@ class NotificationsBarContainer extends Component {
}
}
//reconnect
let retrySeconds = 0;
const retrySecondsDep = new Tracker.Dependency;
@ -86,15 +102,24 @@ const setRetrySeconds = (sec = 0) => {
};
let retryInterval = null;
const startCounter = (sec) => {
clearInterval(retryInterval);
let timeRemainingInterval = null;
const startCounterRetry = (sec) => {
clearInterval(retryInterval);
setRetrySeconds(sec);
retryInterval = setInterval(() => {
setRetrySeconds(getRetrySeconds() - 1);
}, 1000);
};
const startCounterTimeRemaining = (sec) => {
clearInterval(timeRemainingInterval);
setTimeRemaining(sec);
timeRemainingInterval = setInterval(() => {
setTimeRemaining(getTimeRemaining() - 1);
}, 1000);
};
// breakout
let timeRemaining = 0;
const timeRemainingDep = new Tracker.Dependency;
@ -111,15 +136,6 @@ const setTimeRemaining = (sec = 0) => {
}
};
let timeRemainingInterval = null;
const startTimeRemainingCounter = (sec) => {
clearInterval(timeRemainingInterval);
setTimeRemaining(sec);
timeRemainingInterval = setInterval(() => {
setTimeRemaining(getTimeRemaining() - 1);
}, 1000);
};
export default injectIntl(createContainer(({ intl }) => {
const { status, connected, retryCount, retryTime } = Meteor.status();
let data = {};
@ -136,7 +152,8 @@ export default injectIntl(createContainer(({ intl }) => {
data.message = intl.formatMessage(intlMessages.connectingMessage);
break;
case STATUS_WAITING:
startCounter(Math.round((retryTime - (new Date()).getTime()) / 1000));
const sec = Math.round((retryTime - (new Date()).getTime()) / 1000);
startCounterRetry(sec);
data.message = intl.formatMessage(
intlMessages.waitingMessage,
{ seconds: getRetrySeconds() }
@ -147,20 +164,31 @@ export default injectIntl(createContainer(({ intl }) => {
const meetingId = Auth.meetingID;
const breakouts = NavBarService.getBreakouts();
let currentBreakout;
if (breakouts) {
const currentBreakout = breakouts.find(b => b.breakoutMeetingId === meetingId);
currentBreakout = breakouts.find(b => b.breakoutMeetingId === meetingId);
if (currentBreakout) {
roomRemainingTime = currentBreakout.timeRemaining;
if (!timeRemainingInterval && roomRemainingTime) {
startTimeRemainingCounter(roomRemainingTime);
startCounterTimeRemaining(roomRemainingTime);
}
}
}
if (getTimeRemaining()) {
data.color = 'primary';
data.message = `Breakout Room Time Remaining: ${humanizeSeconds(getTimeRemaining())}`;
if (getTimeRemaining() > 0) {
data.message = intl.formatMessage(
intlMessages.breakoutTimeRemaining,
{ time: humanizeSeconds(getTimeRemaining()) }
);
} else {
data.message = intl.formatMessage(intlMessages.breakoutWillClose);
}
} else if (!getTimeRemaining() && currentBreakout) {
data.message = intl.formatMessage(intlMessages.calculatingBreakoutTimeRemaining);
}
data.color = 'primary';
return data;
}, NotificationsBarContainer));