From e1430e6179cf23e36f37e98ef71fb39dcff16394 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 22 Mar 2020 02:26:59 +0000 Subject: [PATCH] Add artist music filter --- src/showplanner/index.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index a54941d..69a08bd 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -241,13 +241,15 @@ function Column({ id, data }: { id: number; data: PlanItem[] }) { function CentralMusicLibrary() { const [track, setTrack] = useState(""); + const [artist, setArtist] = useState(""); const debouncedTrack = useDebounce(track, 1000); + const debouncedArtist = useDebounce(artist, 1000); const [items, setItems] = useState([]); useEffect(() => { - if (debouncedTrack === "") { + if (debouncedTrack === "" && debouncedArtist === "") { return; } - searchForTracks("", track).then(tracks => { + searchForTracks(artist, track).then(tracks => { tracks.forEach(track => { const id = itemId(track); if (!(id in CML_CACHE)) { @@ -256,7 +258,7 @@ function CentralMusicLibrary() { }); setItems(tracks); }); - }, [debouncedTrack]); + }, [debouncedTrack, debouncedArtist]); return ( <> setTrack(e.target.value)} /> + setArtist(e.target.value)} + /> {(provided, snapshot) => (