-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- use `s` route for series and episode information
- Loading branch information
1 parent
5982c9a
commit 2d1667a
Showing
23 changed files
with
469 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 35 additions & 11 deletions
46
src/pages/ScreenRouting/mediaScreens/MediaSeries/MediaSeries.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,50 @@ | ||
import type { ScreenComponent } from '#types/screens'; | ||
import { getSeriesPlaylistIdFromCustomParams } from '#src/utils/media'; | ||
import SeriesRedirect from '#src/containers/SeriesRedirect/SeriesRedirect'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Navigate } from 'react-router'; | ||
|
||
import { seriesURL } from '#src/utils/formatting'; | ||
import { useSeriesData } from '#src/hooks/series/useSeriesData'; | ||
import ErrorPage from '#components/ErrorPage/ErrorPage'; | ||
import { useWatchHistoryStore } from '#src/stores/WatchHistoryStore'; | ||
import type { PlaylistItem } from '#types/playlist'; | ||
import type { ScreenComponent } from '#types/screens'; | ||
import useQueryParam from '#src/hooks/useQueryParam'; | ||
import Loading from '#src/pages/Loading/Loading'; | ||
import { useWatchHistoryStore } from '#src/stores/WatchHistoryStore'; | ||
import { getSeriesPlaylistIdFromCustomParams } from '#src/utils/media'; | ||
|
||
/** | ||
* This media screen is used to redirect a series linking media item to an episode page. | ||
* This media series screen is used to redirect a series linking media item to the series page. | ||
*/ | ||
const MediaSeries: ScreenComponent<PlaylistItem> = ({ data: media, isLoading }) => { | ||
const seriesId = getSeriesPlaylistIdFromCustomParams(media) || ''; | ||
const MediaSeries: ScreenComponent<PlaylistItem> = ({ data: media, isLoading: isMediaLoading }) => { | ||
const { t } = useTranslation('video'); | ||
const play = useQueryParam('play') === '1'; | ||
const feedId = useQueryParam('r'); | ||
|
||
const mediaId = media.mediaid; | ||
|
||
const legacySeriesPlaylistId = getSeriesPlaylistIdFromCustomParams(media) || ''; | ||
const { isLoading: isSeriesLoading, isPlaylistError, data } = useSeriesData(legacySeriesPlaylistId, mediaId); | ||
const { series, playlist: seriesPlaylist } = data || {}; | ||
|
||
// Retrieve watch history for new flow and find an episode of the selected series (if present) | ||
const watchHistoryDictionary = useWatchHistoryStore((state) => state.watchHistory); | ||
const episodeInProgress = watchHistoryDictionary.find((episode) => episode?.seriesId === media.mediaid); | ||
const episodeInProgress = watchHistoryDictionary.find((episode) => episode?.seriesId === mediaId); | ||
|
||
// Prevent rendering the SeriesRedirect multiple times when we are loading data | ||
if (isLoading) { | ||
if (isSeriesLoading || isMediaLoading) { | ||
return <Loading />; | ||
} | ||
|
||
return <SeriesRedirect seriesId={seriesId} mediaId={media.mediaid} episodeId={episodeInProgress?.mediaid} />; | ||
if (isPlaylistError || !seriesPlaylist) { | ||
return <ErrorPage title={t('series_error')} />; | ||
} | ||
|
||
// According to the new approach we use mediaId as a seriesId | ||
return ( | ||
<Navigate | ||
to={seriesURL({ episodeId: episodeInProgress?.mediaid, seriesId: series ? mediaId : legacySeriesPlaylistId, play, playlistId: feedId })} | ||
replace | ||
/> | ||
); | ||
}; | ||
|
||
export default MediaSeries; |
Oops, something went wrong.