Skip to content

Commit

Permalink
Merge pull request #50 from stephane-r/load-channels-videos
Browse files Browse the repository at this point in the history
feat: load channel videos as playlist
  • Loading branch information
stephane-r authored Oct 17, 2023
2 parents bcd986a + 824e814 commit 7b103ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/hooks/useResolveVideosPlaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export const useResolveVideosPlaylist = () => {
videos = remotePlaylist.videos;
}
}
if (location.pathname.includes("/channels/")) {
const [, , authorId] = window.location.pathname.split("/");
const query = queryClient.getQueriesData(
`channels-${authorId}-videos-1`,
)[0][1] as { data: Video[] };
videos = query.data;
}
if (location.pathname === "/favorites") {
videos = getFavoritePlaylist().videos.filter(
(video) => video.type === "video",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ChannelDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const VideosTab = memo(() => {

return (
<PaginateDataList
queryKey={`channel-${authorId}-videos`}
queryKey={`channels-${authorId}-videos`}
fetcher={() => getChannelVideos(authorId as string, continuation)}
onSuccess={handleSuccess}
hasNextPage={Boolean(continuation)}
Expand All @@ -136,7 +136,7 @@ const PlaylistsTab = memo(() => {

return (
<PaginateDataList
queryKey={`channel-${authorId}-playlists`}
queryKey={`channels-${authorId}-playlists`}
fetcher={() => getChannelPlaylists(authorId as string, continuation)}
onSuccess={handleSuccess}
hasNextPage={Boolean(continuation)}
Expand Down

0 comments on commit 7b103ba

Please sign in to comment.