diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index 1a34bec8..7cc1c08a 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -4,13 +4,7 @@ - + @@ -77,7 +71,7 @@ export default { "music_albums", "music_playlists", ], - selectedFilter: "all", + selectedFilter: this.$route.query.filter ?? "all", }; }, mounted() { @@ -98,13 +92,21 @@ export default { async fetchResults() { return await await this.fetchJson(this.apiUrl() + "/search", { q: this.$route.query.search_query, - filter: this.selectedFilter, + filter: this.$route.query.filter ?? "all", }); }, async updateResults() { document.title = this.$route.query.search_query + " - Piped"; this.results = this.fetchResults().then(json => (this.results = json)); }, + updateFilter() { + this.$router.replace({ + query: { + search_query: this.$route.query.search_query, + filter: this.selectedFilter, + }, + }); + }, handleScroll() { if (this.loading || !this.results || !this.results.nextpage) return; if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) { @@ -112,7 +114,7 @@ export default { this.fetchJson(this.apiUrl() + "/nextpage/search", { nextpage: this.results.nextpage, q: this.$route.query.search_query, - filter: this.selectedFilter, + filter: this.$route.query.filter ?? "all", }).then(json => { this.results.nextpage = json.nextpage; this.results.id = json.id;