Skip to content

Commit

Permalink
♻️ remove useTrack usage on Track component
Browse files Browse the repository at this point in the history
  • Loading branch information
Faïssal committed Jan 10, 2024
1 parent 53fec1f commit 185ce17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 4 additions & 6 deletions components/Track/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import usePlaybackControls from "@/hooks/usePlaybackControls";
import useTrack from "@/hooks/useTrack";

import { Button } from "@/components/ui/button";

Expand All @@ -15,7 +14,7 @@ import { TrackContext } from "./context";

export interface TrackProps {
children: React.ReactNode;
track: SpotifyApi.TrackObjectFull | SpotifyApi.TrackObjectSimplified | null;
track: SpotifyApi.TrackObjectFull | null;
}

export interface TrackComposition {
Expand All @@ -34,19 +33,18 @@ const Track: React.FC<TrackProps> & TrackComposition = ({
track,
}) => {
const { playSong } = usePlaybackControls();
const currentTrack = useTrack(track?.id);

if (!currentTrack) return null;
if (!track) return null;

return (
<TrackContext.Provider
value={{
track: currentTrack,
track,
}}
>
<Button
className="group shadow-none transition-all duration-300 flex items-center justify-between p-0 pr-2 sm:pr-4 min-h-[56px] h-full w-full cursor-default bg-transparent hover:bg-[#66677070] hover:text-white"
onDoubleClick={() => playSong(currentTrack)}
onDoubleClick={() => playSong(track)}
>
{children}
</Button>
Expand Down
4 changes: 1 addition & 3 deletions components/TrackList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ type TrackListOptions = {
interface TrackListProps {
options: TrackListOptions;
title?: string;
tracks:
| (SpotifyApi.TrackObjectFull | null)[]
| (SpotifyApi.TrackObjectSimplified | null)[];
tracks: (SpotifyApi.TrackObjectFull | null)[];
}

const TrackList: React.FC<TrackListProps> = ({ options, title, tracks }) => {
Expand Down

0 comments on commit 185ce17

Please sign in to comment.