bigbluebutton-Github/bigbluebutton-html5/imports/api/timer/server/modifiers/addTimer.js
Arthurk12 f5a5a960ba feat(timer): adds more songs
Adds 2 more songs to the timer, which can be switched using the radio
buttons inside timer panel.
Changed the music loop logic to make it gapless.
2023-05-18 15:29:35 -03:00

43 lines
955 B
JavaScript

import { check } from 'meteor/check';
import Timer from '/imports/api/timer';
import Logger from '/imports/startup/server/logger';
import { TRACKS, 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,
track: TRACKS[0],
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);
}