4db28a2824
* Revert "Delete bbb-icons-ori.woff" This reverts commit84937a0d07
. * Revert "Add files via upload" This reverts commit391434445a
. * Revert "Delete bbb-icons.woff" This reverts commit7c245c666d
. * Revert "Add files via upload" This reverts commit6f8c764c4b
. * Revert "Delete tmp.woff" This reverts commit5141e65359
. * Revert "Add files via upload" This reverts commitc8f7b17b04
. * Revert "Create tmp.woff" This reverts commit73c4506594
. * Revert "Delete bbb-icons.woff" This reverts commit9d01d58527
. * Revert "Revert "Delete bbb-icons.woff"" This reverts commitd221d290cd
. * Revert "Revert "Revert "Delete bbb-icons.woff""" This reverts commitc415ff02d1
. * Revert "Revert "Delete bbb-icons.woff"" This reverts commitd221d290cd
. * Revert "Revert "Create tmp.woff"" This reverts commit267dc412d5
. * Revert "Delete bbb-icons-ori.woff" This reverts commit84937a0d07
. * Revert "Delete bbb-icons.woff" This reverts commit7c245c666d
. * Revert "Add files via upload" This reverts commit6f8c764c4b
. * Revert "Add files via upload" This reverts commitc8f7b17b04
. * Revert "Create tmp.woff" This reverts commit73c4506594
. * Revert "Delete bbb-icons.woff" This reverts commit9d01d58527
. * Revert "Revert "Delete bbb-icons.woff"" This reverts commit64a48f2bd6
. * Revert "Revert "Revert "Delete bbb-icons.woff""" This reverts commit9d1b4a068a
. * Revert "Revert "Revert "Revert "Delete bbb-icons.woff"""" This reverts commitb60491d933
. * Revert "Revert "Revert "Revert "Revert "Delete bbb-icons.woff""""" This reverts commit16e357091d
. * Revert "Revert "Revert "Revert "Revert "Revert "Delete bbb-icons.woff"""""" This reverts commite0b70f2055
. * Revert "Revert "Revert "Revert "Revert "Revert "Revert "Delete bbb-icons.woff""""""" This reverts commit7b1bde97ed
. * Update UsersMgs.scala * Update selectRandomViewer.js * Update clearRandomlySelectedUser.js * Update addMeeting.js * Update updateRandomViewer.js * Update component.jsx * Update container.jsx * Update component.jsx * Update container.jsx * Update styles.scss * Update en.json * Update SelectRandomViewerReqMsgHdlr.scala * code simplification * in case only one person to be selected * Update en.json * Create en.json * Update en.json * Update component.jsx * Update styles.scss * Update en.json * Update updateRandomViewer.js Fix a typo * Update component.jsx When the presenter is moved to a viewer, in the modal of ex-presenter "somebody is selected" should be displayed. Before this modification, "somebody is the only viewer" was displayed. * add a comment explaining why a condition is needed. * Update en.json * Update en.json * revert (due to the rename UserMgs -> UserMsgs) * Update UsersMsgs.scala
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
import Meetings from '/imports/api/meetings';
|
|
import Logger from '/imports/startup/server/logger';
|
|
import { check } from 'meteor/check';
|
|
|
|
export default function updateRandomUser(meetingId, userIds, choice, requesterId) {
|
|
check(meetingId, String);
|
|
check(userIds, Array);
|
|
check(choice, Number);
|
|
check(requesterId, String);
|
|
|
|
const selector = {
|
|
meetingId,
|
|
};
|
|
|
|
const userList = [];
|
|
if (choice < 0) { // no viewer
|
|
userList.push([requesterId,0]);
|
|
} else if (userIds.length == 1) {
|
|
userList.push([userIds[0],0]);
|
|
} else {
|
|
const intervals = [0, 200, 450, 750, 1100, 1500];
|
|
while (intervals.length > 0) {
|
|
const userId = userIds[Math.floor(Math.random() * userIds.length )];
|
|
if (userList.length != 0 && userList[userList.length-1][0] == userId) {// prevent same viewer from being selected sequentially
|
|
continue;
|
|
}
|
|
userList.push([userId, intervals.shift()]);
|
|
}
|
|
userList[userList.length-1][0] = userIds[choice]; // last one should be chosen in akka-app
|
|
}
|
|
|
|
if (userIds.length == 2) {
|
|
// I don't like this.. When the userList is same as previous one, we need to change it a bit to make sure that clients does not skip the change in MongoDB
|
|
const previousMeeting = Meetings.findOne(selector, { fields: {randomlySelectedUser:1}});
|
|
if (previousMeeting.randomlySelectedUser.length != 0 && userList[0][0] == previousMeeting.randomlySelectedUser[0][0]) {
|
|
userList[0][0] = userList[1][0];
|
|
}
|
|
}
|
|
|
|
const modifier = {
|
|
$set: {
|
|
randomlySelectedUser: userList,
|
|
},
|
|
};
|
|
|
|
try {
|
|
const { insertedId } = Meetings.upsert(selector, modifier);
|
|
if (insertedId) {
|
|
Logger.info(`Set randomly selected userId and interval = ${userList} by requesterId=${requesterId} in meeitingId=${meetingId}`);
|
|
}
|
|
} catch (err) {
|
|
Logger.error(`Setting randomly selected userId and interval = ${userList} by requesterId=${requesterId} in meetingId=${meetingId}`);
|
|
}
|
|
}
|