]> git.localhorst.tv Git - alttp.git/commitdiff
more links
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 9 Aug 2023 11:07:27 +0000 (13:07 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 9 Aug 2023 11:07:27 +0000 (13:07 +0200)
app/Models/Episode.php
resources/js/components/episodes/Crew.js
resources/js/components/episodes/Item.js
resources/js/helpers/Episode.js
resources/js/i18n/de.js
resources/js/i18n/en.js

index 1c16f7f4a9ac7f8fab1bf2719c666514fa2c45cc..7d3175c4778e19b72d9f9558610d9518a7103410 100644 (file)
@@ -39,7 +39,6 @@ class Episode extends Model
 
        protected $hidden = [
                'created_at',
-               'ext_id',
                'updated_at',
        ];
 
index 76a38a6604852733cb38a6fa32a3b44aab0ee51c..e645edbba17108a5344688ef60be85a9ce5d2a90 100644 (file)
@@ -6,6 +6,12 @@ import { useTranslation } from 'react-i18next';
 import CrewMember from './CrewMember';
 import Icon from '../common/Icon';
 import { compareCrew } from '../../helpers/Crew';
+import {
+       getSGLanguages,
+       getSGSignupLink,
+       hasPassed,
+       hasSGRestream,
+} from '../../helpers/Episode';
 import { canApplyForEpisode } from '../../helpers/permissions';
 import { withUser } from '../../helpers/UserContext';
 
@@ -22,8 +28,26 @@ const Crew = ({ episode, onApply, user }) => {
                episode.crew.filter(c => c.role === 'setup').sort(compareCrew)
        , [episode]);
 
+       const sgLanguages = React.useMemo(() =>
+               getSGLanguages(episode)
+       , [episode]);
+
+       const showCommentators = React.useMemo(() =>
+               commentators.length || (!hasPassed(episode) && (
+                       canApplyForEpisode(user, episode, 'commentary') ||
+                       hasSGRestream(episode)
+               ))
+       , [commentators, episode, user]);
+
+       const showTracker = React.useMemo(() =>
+               trackers.length || (!hasPassed(episode) && (
+                       canApplyForEpisode(user, episode, 'tracking') ||
+                       hasSGRestream(episode)
+               ))
+       , [episode, trackers, user]);
+
        return <Row className="episode-crew">
-               {commentators.length || canApplyForEpisode(user, episode, 'commentary') ?
+               {showCommentators ?
                        <Col md>
                                <div className="fs-5">
                                        <Icon.MICROPHONE className="ms-3 me-2" title="" />
@@ -42,9 +66,23 @@ const Crew = ({ episode, onApply, user }) => {
                                                </Button>
                                        </div>
                                : null}
+                               {hasSGRestream(episode) ?
+                                       <div className="button-bar m-2">
+                                               {sgLanguages.map(lang =>
+                                                       <Button
+                                                               href={getSGSignupLink(episode, lang, 'commentator')}
+                                                               key={lang}
+                                                               target="_blank"
+                                                               variant="outline-secondary"
+                                                       >
+                                                               {`${t('episodes.sgSignUp')} ${lang.toUpperCase()}`}
+                                                       </Button>
+                                               )}
+                                       </div>
+                               : null}
                        </Col>
                : null}
-               {trackers.length || canApplyForEpisode(user, episode, 'tracking') ?
+               {showTracker ?
                        <Col md>
                                <div className="fs-5">
                                        <Icon.MOUSE className="ms-3 me-2" title="" />
@@ -63,6 +101,20 @@ const Crew = ({ episode, onApply, user }) => {
                                                </Button>
                                        </div>
                                : null}
+                               {hasSGRestream(episode) ?
+                                       <div className="button-bar m-2">
+                                               {sgLanguages.map(lang =>
+                                                       <Button
+                                                               href={getSGSignupLink(episode, lang, 'tracker')}
+                                                               key={lang}
+                                                               target="_blank"
+                                                               variant="outline-secondary"
+                                                       >
+                                                               {`${t('episodes.sgSignUp')} ${lang.toUpperCase()}`}
+                                                       </Button>
+                                               )}
+                                       </div>
+                               : null}
                        </Col>
                : null}
                {techies.length ?
index d7c4bab4ff7d68245e87ff84f5a3cabe243fb554..03cb6febd827301ff7d0a8442a11044b3e95f23a 100644 (file)
@@ -1,4 +1,3 @@
-import moment from 'moment';
 import PropTypes from 'prop-types';
 import React from 'react';
 import { Button } from 'react-bootstrap';
@@ -10,17 +9,10 @@ import Crew from './Crew';
 import MultiLink from './MultiLink';
 import Players from './Players';
 import Icon from '../common/Icon';
+import { hasPassed, hasSGRestream, isActive } from '../../helpers/Episode';
 import { canApplyForEpisode, canRestreamEpisode } from '../../helpers/permissions';
 import { withUser } from '../../helpers/UserContext';
 
-const isActive = episode => {
-       if (!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);
-};
-
 const Item = ({ episode, onAddRestream, onApply, onEditRestream, user }) => {
        const { t } = useTranslation();
 
@@ -94,18 +86,24 @@ const Item = ({ episode, onAddRestream, onApply, onEditRestream, user }) => {
                        {hasPlayers ?
                                <Players players={episode.players} />
                        : null}
-                       {(episode.crew && episode.crew.length)
+                       {(episode.crew && episode.crew.length) || (!hasPassed(episode) && (
+                                       hasSGRestream(episode)
                                        || canApplyForEpisode(user, episode, 'commentary')
-                                       || canApplyForEpisode(user, episode, 'tracking') ?
+                                       || canApplyForEpisode(user, episode, 'tracking')
+                       )) ?
                                <div className="mb-3">
                                        <Crew episode={episode} onApply={onApply} />
                                </div>
                        : null}
                        {episode.event ?
                                <div className="episode-event mt-auto">
-                                       <Link className="event-link" to={`/events/${episode.event.name}`}>
-                                               {episode.event.title}
-                                       </Link>
+                                       {episode.event.description_id ?
+                                               <Link className="event-link" to={`/events/${episode.event.name}`}>
+                                                       {episode.event.title}
+                                               </Link>
+                                       :
+                                               episode.event.title
+                                       }
                                </div>
                        : null}
                </div>
@@ -121,6 +119,7 @@ Item.propTypes = {
                })),
                event: PropTypes.shape({
                        corner: PropTypes.string,
+                       description_id: PropTypes.number,
                        name: PropTypes.string,
                        title: PropTypes.string,
                }),
index 60c1a7b9f77976e6c640aefbebeec644a5538c26..696d39a811385f9a7ab357af777ea84377b1da53 100644 (file)
@@ -1,3 +1,5 @@
+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);
@@ -14,6 +16,48 @@ export const acceptsCrew = episode => {
                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);
 };
index 28848e6462ae61cdce2ea4661fb09a87946ebf41..e55885ff11dea4d448c95cc72938a7d1a6d8d21a 100644 (file)
@@ -123,6 +123,7 @@ export default {
                                title: 'Restream',
                        },
                        setup: 'Setup',
+                       sgSignUp: 'SG Anmeldung',
                        startTime: '{{ date, LL LT }} Uhr',
                        tracking: 'Tracking',
                },
index 4f4038a9310e28607454def2c3945a20a08b2a67..52c9031d8362b02659a4a6193ed20d0474fed7db 100644 (file)
@@ -123,6 +123,7 @@ export default {
                                title: 'Restream',
                        },
                        setup: 'Setup',
+                       sgSignUp: 'SG Signup',
                        startTime: '{{ date, LL LT }}',
                        tracking: 'Tracking',
                },