From d695172804e73a0077066665f28bb5806b71314c Mon Sep 17 00:00:00 2001 From: KRTirtho Date: Thu, 18 Mar 2021 11:11:03 +0600 Subject: [PATCH] Search & SearchResultPlaylist see all added. Spotify Infinite Query added for infinite scroll --- src/components/Home.tsx | 7 ++-- src/components/PlaylistGenreView.tsx | 35 +++++++++++-------- src/components/PlaylistView.tsx | 30 ++++++++-------- src/components/Search.tsx | 29 +++++++++------ .../SearchResultPlaylistCollection.tsx | 35 +++++++++++++++++++ src/conf.ts | 3 +- src/hooks/useSpotifyApi.ts | 3 -- src/hooks/useSpotifyInfiniteQuery.ts | 28 +++++++++++++++ src/routes.tsx | 8 ++++- tsconfig.json | 4 +++ 10 files changed, 135 insertions(+), 47 deletions(-) create mode 100644 src/components/SearchResultPlaylistCollection.tsx create mode 100644 src/hooks/useSpotifyInfiniteQuery.ts diff --git a/src/components/Home.tsx b/src/components/Home.tsx index 6164ec17..359aea05 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -75,8 +75,11 @@ const CategoryCard = ({ id, name }: CategoryCardProps) => { { initialData: [] } ); - function goToGenre() { - history.push(`/genre/playlists/${id}`, { name }); + function goToGenre(native: any) { + const mouse = new QMouseEvent(native); + if (mouse.button() === 1) { + history.push(`/genre/playlists/${id}`, { name }); + } } if (isError) { return <>; diff --git a/src/components/PlaylistGenreView.tsx b/src/components/PlaylistGenreView.tsx index 62c847dc..91471df2 100644 --- a/src/components/PlaylistGenreView.tsx +++ b/src/components/PlaylistGenreView.tsx @@ -1,5 +1,5 @@ -import { Direction } from "@nodegui/nodegui"; -import { BoxView, ScrollArea, Text, View, GridView, GridColumn, GridRow } from "@nodegui/react-nodegui"; +import { QAbstractButtonSignals } from "@nodegui/nodegui"; +import { Button, ScrollArea, Text, View } from "@nodegui/react-nodegui"; import React from "react"; import { useLocation, useParams } from "react-router"; import { QueryCacheKeys } from "../conf"; @@ -12,11 +12,23 @@ function PlaylistGenreView() { const location = useLocation<{ name: string }>(); const { data: playlists } = useSpotifyQuery( [QueryCacheKeys.genrePlaylists, id], - (spotifyApi) => spotifyApi.getPlaylistsForCategory(id) - .then((playlistsRes) => playlistsRes.body.playlists.items), + (spotifyApi) => spotifyApi.getPlaylistsForCategory(id).then((playlistsRes) => playlistsRes.body.playlists.items), { initialData: [] } - ) + ); + return ; +} + +export default PlaylistGenreView; + +interface GenreViewProps { + heading: string; + playlists: SpotifyApi.PlaylistObjectSimplified[]; + loadMore?: QAbstractButtonSignals["clicked"]; + isLoadable?: boolean; +} + +export function GenreView({ heading, playlists, loadMore, isLoadable }: GenreViewProps) { const playlistGenreViewStylesheet = ` #genre-container{ flex-direction: column; @@ -38,25 +50,18 @@ function PlaylistGenreView() { width: 330px; } `; - return ( - {`

${location.state.name}

`}
+ {`

${heading}

`}
{playlists?.map((playlist, index) => { - return ( - - ); + return ; })} + {loadMore &&