Commit 34e38491 authored by Agate's avatar Agate 💬

Better cards on search view, now throttle search api calls

parent 9cfdf306
......@@ -9,15 +9,19 @@
</div>
<template v-if="query.length > 0">
<h3 class="ui title">Artists</h3>
<div v-if="results.artists.length > 0" class="ui cards">
<artist-card :artist="artist" :key="artist.id" v-for="artist in results.artists"></artist-card>
<div v-if="results.artists.length > 0" class="ui stackable three column grid">
<div class="column" :key="artist.id" v-for="artist in results.artists">
<artist-card class="fluid" :artist="artist" ></artist-card>
</div>
</div>
<p v-else>Sorry, we did not found any artist matching your query</p>
</template>
<template v-if="query.length > 0">
<h3 class="ui title">Albums</h3>
<div v-if="results.albums.length > 0" class="ui cards">
<album-card :album="album" :key="album.id" v-for="album in results.albums"></album-card>
<div v-if="results.albums.length > 0" class="ui stackable three column grid">
<div class="column" :key="album.id" v-for="album in results.albums">
<album-card class="fluid" :album="album" ></album-card>
</div>
</div>
<p v-else>Sorry, we did not found any album matching your query</p>
</template>
......@@ -71,7 +75,18 @@ export default {
let params = {
query: this.query
}
this.$http.get(SEARCH_URL, {params: params}).then((response) => {
this.$http.get(SEARCH_URL, {
params: params,
before (request) {
// abort previous request, if exists
if (this.previousRequest) {
this.previousRequest.abort()
}
// set previous request on Vue instance
this.previousRequest = request
}
}).then((response) => {
self.results = self.castResults(response.data)
self.isLoading = false
})
......
......@@ -54,7 +54,7 @@ import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon'
export default {
props: {
album: {type: Object},
mode: {type: String, default: 'simple'}
mode: {type: String, default: 'rich'}
},
components: {
TrackFavoriteIcon
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment