Browse Source

Search songs/playlists by title/description

pull/1/head
QuickMythril 8 months ago
parent
commit
78f9989877
  1. 2
      src/components/SearchInput.tsx
  2. 2
      src/components/SearchInputPlaylist.tsx
  3. 8
      src/hooks/fetchSongs.ts

2
src/components/SearchInput.tsx

@ -20,7 +20,7 @@ const SearchInput = () => {
} }
return ( return (
<Input <Input
placeholder="What do you want to listen to? by title" placeholder="What do you want to listen to?"
onChange={(e) => dispatch(setQueriedValue(e.target.value))} onChange={(e) => dispatch(setQueriedValue(e.target.value))}
onKeyDown={handleInputKeyDown} onKeyDown={handleInputKeyDown}
/> />

2
src/components/SearchInputPlaylist.tsx

@ -30,7 +30,7 @@ export const SearchInputPlaylist = () => {
return ( return (
<div className="flex items-center"> <div className="flex items-center">
<Input <Input
placeholder="What do you want to listen to? by title" placeholder="What do you want to listen to?"
onChange={(e) => { onChange={(e) => {
dispatch(setQueriedValuePlaylist(e.target.value)) dispatch(setQueriedValuePlaylist(e.target.value))
}} }}

8
src/hooks/fetchSongs.ts

@ -120,9 +120,9 @@ export const useFetchSongs = () => {
if (!queriedValue) return if (!queriedValue) return
dispatch(setIsLoadingGlobal(true)) dispatch(setIsLoadingGlobal(true))
const offset = songListQueried.length const offset = songListQueried.length
const query = `earbump_song_` const identifier = `earbump_song_`
const replaceSpacesWithUnderscore = queriedValue.toLowerCase().replace(/ /g, '_'); const replaceSpacesWithUnderscore = queriedValue.toLowerCase().replace(/ /g, '_');
const identifier = replaceSpacesWithUnderscore const query = replaceSpacesWithUnderscore
const url = `/arbitrary/resources/search?mode=ALL&service=AUDIO&query=${query}&identifier=${identifier}&limit=20&includemetadata=true&offset=${offset}&reverse=true&excludeblocked=true&includestatus=true` const url = `/arbitrary/resources/search?mode=ALL&service=AUDIO&query=${query}&identifier=${identifier}&limit=20&includemetadata=true&offset=${offset}&reverse=true&excludeblocked=true&includestatus=true`
const response = await fetch(url, { const response = await fetch(url, {
method: 'GET', method: 'GET',
@ -530,9 +530,9 @@ export const useFetchSongs = () => {
try { try {
if (!queriedValuePlaylist) return if (!queriedValuePlaylist) return
const offset = playlistQueried.length const offset = playlistQueried.length
const query = `earbump_playlist_` const identifier = `earbump_playlist_`
const replaceSpacesWithUnderscore = queriedValuePlaylist.toLowerCase().replace(/ /g, '_'); const replaceSpacesWithUnderscore = queriedValuePlaylist.toLowerCase().replace(/ /g, '_');
const identifier = replaceSpacesWithUnderscore const query = replaceSpacesWithUnderscore
const url = `/arbitrary/resources/search?mode=ALL&service=PLAYLIST&query=${query}&identifier=${identifier}&limit=20&includemetadata=false&offset=${offset}&reverse=true&excludeblocked=true&includestatus=false` const url = `/arbitrary/resources/search?mode=ALL&service=PLAYLIST&query=${query}&identifier=${identifier}&limit=20&includemetadata=false&offset=${offset}&reverse=true&excludeblocked=true&includestatus=false`
const response = await fetch(url, { const response = await fetch(url, {
method: 'GET', method: 'GET',

Loading…
Cancel
Save