From 929b1c07c009caa01b222ff0e3432d8e2b39fb96 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Tue, 15 Jun 2021 01:15:19 +0530 Subject: [PATCH] Add support for search filters. --- src/components/SearchResults.vue | 42 +++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index c2d8cd72..5c4e1737 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -3,6 +3,21 @@ {{ $route.query.search_query }} + Filter: + + +
+
{{ result.uploaderName }} -
{{ result.videos }} Videos
+
{{ result.videos }} Videos

@@ -58,6 +73,17 @@ export default { data() { return { results: null, + availableFilters: [ + "all", + "videos", + "channels", + "playlists", + "music_songs", + "music_videos", + "music_albums", + "music_playlists", + ], + selectedFilter: "all", }; }, mounted() { @@ -75,7 +101,11 @@ export default { methods: { async fetchResults() { return await await this.fetchJson( - Constants.BASE_URL + "/search?q=" + encodeURIComponent(this.$route.query.search_query), + Constants.BASE_URL + + "/search?q=" + + encodeURIComponent(this.$route.query.search_query) + + "&filter=" + + this.selectedFilter, ); }, async updateResults() { @@ -89,12 +119,12 @@ export default { this.fetchJson( Constants.BASE_URL + "/nextpage/search" + - "?url=" + + "?nextpage=" + encodeURIComponent(this.results.nextpage) + - "&id=" + - encodeURIComponent(this.results.id) + "&q=" + - encodeURIComponent(this.$route.query.search_query), + encodeURIComponent(this.$route.query.search_query) + + "&filter=" + + this.selectedFilter, ).then(json => { this.results.nextpage = json.nextpage; this.results.id = json.id;