[web] Fix empty empty queries to not be saved

This commit is contained in:
Alain Nussbaumer 2025-03-22 16:05:12 +01:00
parent ed8e5710f3
commit 709b60858d
2 changed files with 24 additions and 33 deletions

View File

@ -7,7 +7,6 @@
<div class="field">
<div class="control has-icons-left">
<input
ref="search_field"
v-model="searchStore.query"
class="input is-rounded"
type="text"
@ -163,23 +162,18 @@ export default {
})
},
search(event) {
if (event) {
this.types = SEARCH_TYPES
this.limit = PAGE_SIZE
if (this.searchStore.query) {
if (event) {
this.types = SEARCH_TYPES
this.limit = PAGE_SIZE
}
this.searchStore.query = this.searchStore.query.trim()
this.reset()
this.types.forEach((type) => {
this.searchItems(type)
})
this.searchStore.add(this.searchStore.query)
}
this.searchStore.query = this.searchStore.query.trim()
if (
!this.searchStore.query ||
!this.searchStore.query.replace(/^query:/u, '')
) {
this.$refs.search_field.focus()
return
}
this.reset()
this.types.forEach((type) => {
this.searchItems(type)
})
this.searchStore.add(this.searchStore.query)
},
searchItems(type) {
const music = type !== 'audiobook' && type !== 'podcast'

View File

@ -7,7 +7,6 @@
<div class="field">
<div class="control has-icons-left">
<input
ref="search_field"
v-model="searchStore.query"
class="input is-rounded"
type="text"
@ -152,22 +151,20 @@ export default {
})
},
search(event) {
if (event) {
this.types = SEARCH_TYPES
this.parameters.limit = PAGE_SIZE
}
this.searchStore.query = this.searchStore.query.trim()
if (!this.searchStore.query) {
this.$refs.search_field.focus()
return
}
this.reset()
this.searchItems().then((data) => {
this.types.forEach((type) => {
this.results.set(type, data[`${type}s`])
if (this.searchStore.query) {
if (event) {
this.types = SEARCH_TYPES
this.parameters.limit = PAGE_SIZE
}
this.searchStore.query = this.searchStore.query.trim()
this.reset()
this.searchItems().then((data) => {
this.types.forEach((type) => {
this.results.set(type, data[`${type}s`])
})
})
})
this.searchStore.add(this.searchStore.query)
this.searchStore.add(this.searchStore.query)
}
},
searchItems() {
return webapi.spotify().then(({ data }) => {