[web] Fix the error when the library search only contains the keyword query:

The check for a valid query is not yet implemented though.
This commit is contained in:
Alain Nussbaumer 2024-03-21 20:57:46 +01:00
parent db4e145080
commit a34e14f483

View File

@ -312,7 +312,7 @@ export default {
methods: { methods: {
search(route) { search(route) {
this.search_query = route.query.query?.trim() this.search_query = route.query.query?.trim()
if (!this.search_query) { if (!this.search_query || !this.search_query.replace(/^query:/u, '')) {
this.$refs.search_field.focus() this.$refs.search_field.focus()
return return
} }
@ -325,11 +325,11 @@ export default {
searchMusic(query) { searchMusic(query) {
if ( if (
query.type.indexOf('track') < 0 && !query.type.includes('track') &&
query.type.indexOf('artist') < 0 && !query.type.includes('artist') &&
query.type.indexOf('album') < 0 && !query.type.includes('album') &&
query.type.indexOf('playlist') < 0 && !query.type.includes('playlist') &&
query.type.indexOf('composer') < 0 !query.type.includes('composer')
) { ) {
return return
} }
@ -337,7 +337,7 @@ export default {
type: query.type type: query.type
} }
if (query.query.startsWith('query:')) { if (query.query.startsWith('query:')) {
searchParams.expression = `${query.query.replace(/^query:/u, '').trim()} and media_kind is music` searchParams.expression = `(${query.query.replace(/^query:/u, '').trim()}) and media_kind is music`
} else { } else {
searchParams.query = query.query searchParams.query = query.query
searchParams.media_kind = 'music' searchParams.media_kind = 'music'
@ -356,7 +356,7 @@ export default {
}, },
searchAudiobooks(query) { searchAudiobooks(query) {
if (query.type.indexOf('audiobook') < 0) { if (!query.type.includes('audiobook')) {
return return
} }
const parameters = { const parameters = {
@ -378,7 +378,7 @@ export default {
}, },
searchPodcasts(query) { searchPodcasts(query) {
if (query.type.indexOf('podcast') < 0) { if (!query.type.includes('podcast')) {
return return
} }
const parameters = { const parameters = {