2023-05-11 04:03:20 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
|
|
|
|
const TIMER_CONFIG = Meteor.settings.public.timer;
|
|
|
|
|
2020-04-26 03:03:35 +08:00
|
|
|
const MILLI_IN_MINUTE = 60000;
|
|
|
|
|
2022-02-02 03:05:02 +08:00
|
|
|
const TRACKS = [
|
|
|
|
'noTrack',
|
|
|
|
'track1',
|
|
|
|
'track2',
|
|
|
|
'track3',
|
|
|
|
];
|
|
|
|
|
2023-05-11 04:03:20 +08:00
|
|
|
const isEnabled = () => TIMER_CONFIG.enabled;
|
|
|
|
|
2020-04-26 03:03:35 +08:00
|
|
|
const getDefaultTime = () => TIMER_CONFIG.time * MILLI_IN_MINUTE;
|
|
|
|
|
2023-05-03 04:46:33 +08:00
|
|
|
const getInitialState = () => {
|
|
|
|
const time = getDefaultTime();
|
|
|
|
check(time, Number);
|
|
|
|
|
|
|
|
return {
|
|
|
|
stopwatch: true,
|
|
|
|
running: false,
|
|
|
|
time,
|
|
|
|
accumulated: 0,
|
|
|
|
timestamp: 0,
|
|
|
|
track: TRACKS[0],
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-02-02 03:05:02 +08:00
|
|
|
const isTrackValid = (track) => TRACKS.includes(track);
|
|
|
|
|
2023-05-11 04:03:20 +08:00
|
|
|
export {
|
2022-02-02 03:05:02 +08:00
|
|
|
TRACKS,
|
2023-05-11 04:03:20 +08:00
|
|
|
isEnabled,
|
2020-04-26 03:03:35 +08:00
|
|
|
getDefaultTime,
|
2023-05-03 04:46:33 +08:00
|
|
|
getInitialState,
|
2022-02-02 03:05:02 +08:00
|
|
|
isTrackValid,
|
2023-05-11 04:03:20 +08:00
|
|
|
};
|