dbbef569a9
When user enters meeting with music already playing, an event listener is set to play the music only after user interaction. Also, to keep timer more cohesive and reduce complexity of the condition for playing music, timer automatically stops after 90% of users notify that the timer has expired.
43 lines
943 B
JavaScript
43 lines
943 B
JavaScript
import { check } from 'meteor/check';
|
|
import Timer from '/imports/api/timer';
|
|
import Logger from '/imports/startup/server/logger';
|
|
import { getDefaultTime } from '/imports/api/timer/server/helpers';
|
|
|
|
// This method should only be used by the server
|
|
export default function addTimer(meetingId) {
|
|
check(meetingId, String);
|
|
|
|
const selector = {
|
|
meetingId,
|
|
};
|
|
|
|
const time = getDefaultTime();
|
|
check(time, Number);
|
|
|
|
const modifier = {
|
|
meetingId,
|
|
stopwatch: true,
|
|
active: false,
|
|
running: false,
|
|
time,
|
|
accumulated: 0,
|
|
timestamp: 0,
|
|
music: false,
|
|
ended: 0,
|
|
};
|
|
|
|
const cb = (err, numChanged) => {
|
|
if (err) {
|
|
return Logger.error(`Adding timer to the collection: ${err}`);
|
|
}
|
|
|
|
if (numChanged) {
|
|
return Logger.debug(`Added timer meeting=${meetingId}`);
|
|
}
|
|
|
|
return Logger.debug(`Upserted timer meeting=${meetingId}`);
|
|
};
|
|
|
|
return Timer.upsert(selector, modifier, cb);
|
|
}
|