2016-11-07 23:52:39 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-08-12 01:14:50 +08:00
|
|
|
import Breakouts from '/imports/api/2.0/breakouts';
|
2016-11-07 23:52:39 +08:00
|
|
|
|
2016-11-25 03:22:04 +08:00
|
|
|
const getBreakouts = () => Breakouts.find().fetch();
|
2016-11-07 23:52:39 +08:00
|
|
|
|
2016-11-29 03:48:02 +08:00
|
|
|
const getBreakoutJoinURL = (breakout) => {
|
2017-03-17 22:23:00 +08:00
|
|
|
const currentUserId = Auth.userID;
|
2016-11-29 03:48:02 +08:00
|
|
|
|
|
|
|
if (breakout.users) {
|
2017-08-12 01:14:50 +08:00
|
|
|
const user = breakout.users.find(u => u.userId === currentUserId);
|
|
|
|
|
2016-11-29 03:48:02 +08:00
|
|
|
if (user) {
|
|
|
|
const urlParams = user.urlParams;
|
|
|
|
return [
|
|
|
|
window.origin,
|
2017-08-12 01:14:50 +08:00
|
|
|
`html5client/join?sessionToken=${urlParams.sessionToken}`,
|
2016-11-29 03:48:02 +08:00
|
|
|
].join('/');
|
|
|
|
}
|
|
|
|
}
|
2017-08-12 01:14:50 +08:00
|
|
|
return '';
|
2016-11-29 03:48:02 +08:00
|
|
|
};
|
|
|
|
|
2016-11-07 23:52:39 +08:00
|
|
|
export default {
|
|
|
|
getBreakouts,
|
2016-11-29 03:48:02 +08:00
|
|
|
getBreakoutJoinURL,
|
2016-11-07 23:52:39 +08:00
|
|
|
};
|