]> git.localhorst.tv Git - alttp.git/commitdiff
fix crew list
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 30 Jul 2025 14:37:21 +0000 (16:37 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 30 Jul 2025 14:37:21 +0000 (16:37 +0200)
resources/js/components/episodes/Crew.jsx
resources/js/components/episodes/CrewList.jsx
resources/js/components/episodes/Item.jsx

index f1a828954fe48405855f45f5743f68e7e5c9e850..c20021a8fd6d77e482e84ef159f347a827df40a8 100644 (file)
@@ -49,6 +49,10 @@ const Crew = ({ episode }) => {
                ))
        , [episode, trackers, user]);
 
+       const showSgSignup = React.useMemo(() =>
+               !hasPassed(episode) && hasSGRestream(episode)
+       , [episode]);
+
        return <Row className="episode-crew">
                {showCommentators ?
                        <Col xs={6} md>
@@ -67,7 +71,7 @@ const Crew = ({ episode }) => {
                                                </Button>
                                        </div>
                                : null}
-                               {hasSGRestream(episode) ?
+                               {showSgSignup ?
                                        <div className="button-bar m-2">
                                                {sgLanguages.map(lang =>
                                                        <Button
@@ -100,7 +104,7 @@ const Crew = ({ episode }) => {
                                                </Button>
                                        </div>
                                : null}
-                               {hasSGRestream(episode) ?
+                               {showSgSignup ?
                                        <div className="button-bar m-2">
                                                {sgLanguages.map(lang =>
                                                        <Button
index fcc5c7df04f69bf631d3b6a0298d401ee9382b05..082f6237688469a091c896a6a5d8cb6efdcbcc03 100644 (file)
@@ -7,21 +7,22 @@ const CrewList = ({ crews, episode }) => {
        const byChannel = React.useMemo(() => {
                const bc = {};
                crews.forEach((crew) => {
-                       if (!bc[crew.channel_id]) {
-                               bc[crew.channel_id] = {
-                                       channel: episode.channels.find((c) => c.id === crew.channel_id),
+                       const ccid = crew.channel_id || 'none';
+                       if (!bc[ccid]) {
+                               bc[ccid] = {
+                                       channel: episode.channels.find((c) => c.id === ccid),
                                        crews: [],
                                };
                        }
-                       bc[crew.channel_id].crews.push(crew);
+                       bc[ccid].crews.push(crew);
                });
-               return Object.entries(bc).map(([, value]) => value).filter(c => !!c.channel);
+               return Object.entries(bc).map(([, value]) => value);
        }, [crews, episode]);
 
        return <div>
                {byChannel.map(({ channel, crews }) => (
-                       <fieldset className="crew-list" key={channel.id}>
-                               {byChannel.length > 1 ?
+                       <fieldset className="crew-list" key={channel?.id || 'none'}>
+                               {byChannel.length > 1 && channel ?
                                        <legend>{channel.title}</legend>
                                : null}
                                {crews.map((crew) => (
index 401930f8ffe7202e8ae35419b16588d27a0927e5..e8844e21fe6954cc0dfa3b0004294f58f0d3f441 100644 (file)
@@ -30,6 +30,7 @@ const Item = ({ episode }) => {
                'p-2',
                'border',
                'rounded',
+               `episode-${episode.id}`
        ];
        if (isActive(episode)) {
                classNames.push('is-active');
@@ -161,6 +162,7 @@ Item.propTypes = {
                        name: PropTypes.string,
                        title: PropTypes.string,
                }),
+               id: PropTypes.number,
                players: PropTypes.arrayOf(PropTypes.shape({
                })),
                raceroom: PropTypes.string,