From: Daniel Karbach Date: Mon, 20 Feb 2023 20:52:07 +0000 (+0100) Subject: add multilink for episodes without channel X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=4dc1bbd62acf0c18100f4276d26fc87be8968f28;p=alttp.git add multilink for episodes without channel --- diff --git a/resources/js/components/episodes/Item.js b/resources/js/components/episodes/Item.js index 2078c6d..5c69829 100644 --- a/resources/js/components/episodes/Item.js +++ b/resources/js/components/episodes/Item.js @@ -5,13 +5,14 @@ import { useTranslation } from 'react-i18next'; 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); }; @@ -31,6 +32,9 @@ const Item = ({ episode }) => { classNames.push('is-active'); } + const hasChannels = episode.channels && episode.channels.length; + const hasPlayers = episode.players && episode.players.length; + return
{t('schedule.startTime', { date: new Date(episode.start) })} @@ -50,12 +54,15 @@ const Item = ({ episode }) => { : null}
- {episode.channels ? + {hasChannels ? : null} + {!hasChannels && hasPlayers ? + + : null}
- {episode.players && episode.players.length ? + {hasPlayers ? : null} {episode.crew && episode.crew.length ? diff --git a/resources/js/components/episodes/MultiLink.js b/resources/js/components/episodes/MultiLink.js new file mode 100644 index 0000000..b66d2fe --- /dev/null +++ b/resources/js/components/episodes/MultiLink.js @@ -0,0 +1,35 @@ +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
+ +
; +}; + +MultiLink.propTypes = { + players: PropTypes.arrayOf(PropTypes.shape({ + short_name: PropTypes.string, + stream_link: PropTypes.string, + title: PropTypes.string, + })), +}; + +export default MultiLink;