1 import moment from 'moment';
3 export const acceptsComms = episode => {
4 if (!episode || !episode.channels) return false;
5 return !!episode.channels.find(c => c.pivot && c.pivot.accept_comms);
8 export const acceptsTrackers = episode => {
9 if (!episode || !episode.channels) return false;
10 return !!episode.channels.find(c => c.pivot && c.pivot.accept_tracker);
13 export const acceptsCrew = episode => {
14 if (!episode || !episode.channels) return false;
15 return !!episode.channels.find(c =>
16 c.pivot && (c.pivot.accept_comms || c.pivot.accept_tracker));
19 export const getSGLanguages = episode => {
20 if (!episode || !episode.channels) return [];
21 const sgChannels = episode.channels.filter(
22 c => c.stream_link && c.stream_link.startsWith('https://twitch.tv/speedgaming'),
25 sgChannels.forEach(channel => {
26 if (!channel.languages) return;
27 channel.languages.forEach(lang => {
28 if (!langs.includes(lang)) {
36 export const getSGSignupLink = (episode, lang, role) =>
37 `https://speedgaming.org/${lang}/${role}/signup/${episode.ext_id.substr(3)}/`;
39 export const hasPassed = episode => {
40 if (!episode || !episode.start) return false;
42 const end = moment(episode.start).add(episode.estimate, 'seconds');
43 return end.isBefore(now);
46 export const hasSGRestream = episode => {
47 if (!episode || !episode.channels) return false;
48 return !!episode.channels.find(
49 c => c.stream_link && c.stream_link.startsWith('https://twitch.tv/speedgaming'),
53 export const isActive = episode => {
54 if (!episode || !episode.start) return false;
56 const start = moment(episode.start).subtract(10, 'minutes');
57 const end = moment(episode.start).add(episode.estimate, 'seconds');
58 return start.isBefore(now) && end.isAfter(now);
61 export const isEventSelected = (filter, event) => {
62 return (filter.event || []).includes(event.id);
65 export const toggleEventFilter = (events, filter, event) => {
66 const eventFilter = filter.event || [];
67 if (eventFilter.includes(event.id)) {
70 event: eventFilter.filter(id => id !== event.id && events.find(e => e.id === id)),
75 event: [...eventFilter, event.id],