Skip to content

Commit

Permalink
feat(project): support live channel without tv guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Jun 12, 2024
1 parent 6e6b2d6 commit 92564d4
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { Navigate } from 'react-router-dom';
import type { PlaylistItem } from '@jwp/ott-common/types/playlist';
import { isLiveChannel } from '@jwp/ott-common/src/utils/media';
import { liveChannelsURL } from '@jwp/ott-common/src/utils/urlFormatting';

import type { ScreenComponent } from '../../../../../types/screens';
import ErrorPage from '../../../../components/ErrorPage/ErrorPage';
import Loading from '../../../Loading/Loading';
import MediaMovie from '../MediaMovie/MediaMovie';

const MediaLiveChannel: ScreenComponent<PlaylistItem> = ({ data, isLoading }) => {
const liveChannelsId = isLiveChannel(data) ? data.liveChannelsId : undefined;
const liveChannelsId = data.liveChannelsId;

if (data && !isLoading && liveChannelsId) {
return <Navigate to={liveChannelsURL(liveChannelsId, data.mediaid)} replace={true}></Navigate>;
if (isLoading) {
return <Loading />;
}

if (!liveChannelsId) {
return <ErrorPage title="Live channel not found" />;
// this live channel is part of a live channels (TV Guide) page
if (liveChannelsId) {
return <Navigate to={liveChannelsURL(liveChannelsId, data.mediaid)} replace={true}></Navigate>;
}

return <Loading />;
// this live channel is "just" a media item
return <MediaMovie data={data} isLoading={isLoading} />;
};

export default MediaLiveChannel;

0 comments on commit 92564d4

Please sign in to comment.