+import moment from 'moment';
+
export const acceptsComms = episode => {
if (!episode || !episode.channels) return false;
return !!episode.channels.find(c => c.pivot && c.pivot.accept_comms);
c.pivot && (c.pivot.accept_comms || c.pivot.accept_tracker));
};
+export const getSGLanguages = episode => {
+ if (!episode || !episode.channels) return [];
+ const sgChannels = episode.channels.filter(
+ c => c.stream_link && c.stream_link.startsWith('https://twitch.tv/speedgaming'),
+ );
+ const langs = [];
+ sgChannels.forEach(channel => {
+ if (!channel.languages) return;
+ channel.languages.forEach(lang => {
+ if (!langs.includes(lang)) {
+ langs.push(lang);
+ }
+ });
+ });
+ return langs;
+};
+
+export const getSGSignupLink = (episode, lang, role) =>
+ `https://speedgaming.org/${lang}/${role}/signup/${episode.ext_id.substr(3)}/`;
+
+export const hasPassed = episode => {
+ if (!episode || !episode.start) return false;
+ const now = moment();
+ const end = moment(episode.start).add(episode.estimate, 'seconds');
+ return end.isBefore(now);
+};
+
+export const hasSGRestream = episode => {
+ if (!episode || !episode.channels) return false;
+ return !!episode.channels.find(
+ c => c.stream_link && c.stream_link.startsWith('https://twitch.tv/speedgaming'),
+ );
+};
+
+export const isActive = episode => {
+ if (!episode || !episode.start) return false;
+ const now = moment();
+ const start = moment(episode.start).subtract(10, 'minutes');
+ const end = moment(episode.start).add(episode.estimate, 'seconds');
+ return start.isBefore(now) && end.isAfter(now);
+};
+
export const isEventSelected = (filter, event) => {
return (filter.event || []).includes(event.id);
};