From 824e814b3dae8fc4d0485c92755ebea8d6bcb42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane?= Date: Mon, 16 Oct 2023 11:22:34 +0200 Subject: [PATCH] feat: load channel videos as playlist --- src/hooks/useResolveVideosPlaylist.ts | 7 +++++++ src/pages/ChannelDetail.tsx | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hooks/useResolveVideosPlaylist.ts b/src/hooks/useResolveVideosPlaylist.ts index e783a0a..6bec9ea 100644 --- a/src/hooks/useResolveVideosPlaylist.ts +++ b/src/hooks/useResolveVideosPlaylist.ts @@ -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", diff --git a/src/pages/ChannelDetail.tsx b/src/pages/ChannelDetail.tsx index 3aec9f4..6caca1d 100644 --- a/src/pages/ChannelDetail.tsx +++ b/src/pages/ChannelDetail.tsx @@ -118,7 +118,7 @@ const VideosTab = memo(() => { return ( getChannelVideos(authorId as string, continuation)} onSuccess={handleSuccess} hasNextPage={Boolean(continuation)} @@ -136,7 +136,7 @@ const PlaylistsTab = memo(() => { return ( getChannelPlaylists(authorId as string, continuation)} onSuccess={handleSuccess} hasNextPage={Boolean(continuation)}