diff --git a/tubearchivist/www/src/components/VideoList.tsx b/tubearchivist/www/src/components/VideoList.tsx index f56a0ca..cea97fd 100644 --- a/tubearchivist/www/src/components/VideoList.tsx +++ b/tubearchivist/www/src/components/VideoList.tsx @@ -14,8 +14,12 @@ export const VideoList = () => { const [selectedVideoUrl, setSelectedVideoUrl] = useState(); const [viewStyle, setViewStyle] = useState("grid"); const { data: session } = useSession(); - const { data, error, isLoading } = useQuery("videos", () => - getVideos(session.ta_token.token) + const { data, error, isLoading } = useQuery( + ["videos", session?.ta_token?.token], + () => getVideos(session.ta_token.token), + { + enabled: !!session?.ta_token?.token, + } ); const handleSelectedVideo = (video: Datum) => { diff --git a/tubearchivist/www/src/lib/getVideos.ts b/tubearchivist/www/src/lib/getVideos.ts index 7739105..1c46380 100644 --- a/tubearchivist/www/src/lib/getVideos.ts +++ b/tubearchivist/www/src/lib/getVideos.ts @@ -22,5 +22,3 @@ export const getVideos = async (token: string): Promise => { return response.json(); }; - -// b4d4330462c7fc16c51873e45579b29a1a12fc90 diff --git a/tubearchivist/www/src/pages/channel.tsx b/tubearchivist/www/src/pages/channel.tsx index 5165e5f..061ffc7 100644 --- a/tubearchivist/www/src/pages/channel.tsx +++ b/tubearchivist/www/src/pages/channel.tsx @@ -36,8 +36,13 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const Channel: NextPage = () => { const { data: session } = useSession(); const { - data: { data: channels }, - } = useQuery("channels", () => getChannels(session.ta_token.token)); + data: channels, + error, + isLoading, + } = useQuery("channels", () => getChannels(session.ta_token.token), { + enabled: !!session?.ta_token?.token, + }); + const [viewStyle, setViewStyle] = useState("grid"); const handleSetViewstyle = (selectedViewStyle: ViewStyle) => { @@ -104,12 +109,12 @@ const Channel: NextPage = () => { /> -

Total matching channels: {channels?.length}

+

Total matching channels: {channels?.data?.length}

- {!channels ? ( + {!channels.data ? (

No channels found...

) : ( - channels?.map((channel) => { + channels?.data.map((channel) => { return (