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 &&