import Channels from './Channels';
import Crew from './Crew';
+import MultiLink from './MultiLink';
import Players from './Players';
const isActive = episode => {
if (!episode.start) return false;
const now = moment();
- const start = moment(episode.start);
- const end = moment(start).add(episode.estimate, 'seconds');
+ const start = moment(episode.start).subtract(10, 'minutes');
+ const end = moment(episode.start).add(episode.estimate, 'seconds');
return start.isBefore(now) && end.isAfter(now);
};
classNames.push('is-active');
}
+ const hasChannels = episode.channels && episode.channels.length;
+ const hasPlayers = episode.players && episode.players.length;
+
return <div className={classNames.join(' ')}>
<div className="episode-start me-3 fs-4 text-end">
{t('schedule.startTime', { date: new Date(episode.start) })}
: null}
</div>
<div>
- {episode.channels ?
+ {hasChannels ?
<Channels channels={episode.channels} />
: null}
+ {!hasChannels && hasPlayers ?
+ <MultiLink players={episode.players} />
+ : null}
</div>
</div>
- {episode.players && episode.players.length ?
+ {hasPlayers ?
<Players players={episode.players} />
: null}
{episode.crew && episode.crew.length ?
--- /dev/null
+import PropTypes from 'prop-types';
+import React from 'react';
+import { Button } from 'react-bootstrap';
+
+import Icon from '../common/Icon';
+import { getStreamLink } from '../../helpers/Crew';
+
+const MultiLink = ({ players }) => {
+ const streams = players.map(getStreamLink);
+ const names = streams.map(s => s.split('/').pop());
+ const url = `https://multitwitch.tv/${names.join('/')}`;
+
+ return <div className="episode-channel">
+ <Button
+ href={url}
+ rel="noreferer"
+ target="_blank"
+ title="MultiTwitch"
+ variant="outline-twitch"
+ >
+ <Icon.STREAM />
+ {' MultiTwitch'}
+ </Button>
+ </div>;
+};
+
+MultiLink.propTypes = {
+ players: PropTypes.arrayOf(PropTypes.shape({
+ short_name: PropTypes.string,
+ stream_link: PropTypes.string,
+ title: PropTypes.string,
+ })),
+};
+
+export default MultiLink;