Use URLSearchParams

This commit is contained in:
bopol 2021-06-14 23:02:33 +02:00
parent b69cc4c848
commit 818a8709ce
5 changed files with 30 additions and 22 deletions

View file

@ -74,12 +74,13 @@ export default {
if (this.loading || !this.channel || !this.channel.nextpage) return; if (this.loading || !this.channel || !this.channel.nextpage) return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) { if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
this.loading = true; this.loading = true;
let params = new URLSearchParams();
params.append("nextpage", this.channel.nextpage);
this.fetchJson( this.fetchJson(
Constants.BASE_URL + Constants.BASE_URL +
"/nextpage/channels/" + "/nextpage/channels/" +
this.channel.id + this.channel.id +
"?nextpage=" + "?" + params.toString()
encodeURIComponent(this.channel.nextpage),
).then(json => { ).then(json => {
this.channel.relatedStreams.concat(json.relatedStreams); this.channel.relatedStreams.concat(json.relatedStreams);
this.channel.nextpage = json.nextpage; this.channel.nextpage = json.nextpage;

View file

@ -74,12 +74,14 @@ export default {
if (this.loading || !this.playlist || !this.playlist.nextpage) return; if (this.loading || !this.playlist || !this.playlist.nextpage) return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) { if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
this.loading = true; this.loading = true;
let params = new URLSearchParams();
params.append("nextpage", this.playlist.nextpage);
this.fetchJson( this.fetchJson(
Constants.BASE_URL + Constants.BASE_URL +
"/nextpage/playlists/" + "/nextpage/playlists/" +
this.$route.query.list + this.$route.query.list +
"?nextpage=" + "?" +
encodeURIComponent(this.playlist.nextpage), params.toString()
).then(json => { ).then(json => {
this.playlist.relatedStreams.concat(json.relatedStreams); this.playlist.relatedStreams.concat(json.relatedStreams);
this.playlist.nextpage = json.nextpage; this.playlist.nextpage = json.nextpage;

View file

@ -100,12 +100,13 @@ export default {
}, },
methods: { methods: {
async fetchResults() { async fetchResults() {
let params = new URLSearchParams();
params.append("q", this.$route.query.search_query);
params.append("filter", this.selectedFilter)
return await await this.fetchJson( return await await this.fetchJson(
Constants.BASE_URL + Constants.BASE_URL +
"/search?q=" + "/search?" +
encodeURIComponent(this.$route.query.search_query) + params.toString()
"&filter=" +
this.selectedFilter,
); );
}, },
async updateResults() { async updateResults() {
@ -116,15 +117,14 @@ export default {
if (this.loading || !this.results || !this.results.nextpage) return; if (this.loading || !this.results || !this.results.nextpage) return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) { if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
this.loading = true; this.loading = true;
let params = new URLSearchParams();
params.append("nextpage", this.results.nextpage);
params.append("q", this.$route.query.search_query);
params.append("filter", this.selectedFilter);
this.fetchJson( this.fetchJson(
Constants.BASE_URL + Constants.BASE_URL +
"/nextpage/search" + "/nextpage/search?" +
"?nextpage=" + params.toString()
encodeURIComponent(this.results.nextpage) +
"&q=" +
encodeURIComponent(this.$route.query.search_query) +
"&filter=" +
this.selectedFilter,
).then(json => { ).then(json => {
this.results.nextpage = json.nextpage; this.results.nextpage = json.nextpage;
this.results.id = json.id; this.results.id = json.id;

View file

@ -49,8 +49,10 @@ export default {
} }
}, },
async refreshSuggestions() { async refreshSuggestions() {
let params = new URLSearchParams();
params.append("query", this.searchText);
this.searchSuggestions = await this.fetchJson( this.searchSuggestions = await this.fetchJson(
Constants.BASE_URL + "/suggestions?query=" + encodeURI(this.searchText), Constants.BASE_URL + "/suggestions?" + params.toString()
); );
this.searchSuggestions.unshift(this.searchText); this.searchSuggestions.unshift(this.searchText);
this.setSelected(0); this.setSelected(0);

View file

@ -144,14 +144,16 @@ export default {
return this.fetchJson(Constants.BASE_URL + "/streams/" + this.getVideoId()); return this.fetchJson(Constants.BASE_URL + "/streams/" + this.getVideoId());
}, },
async fetchSponsors() { async fetchSponsors() {
let params = new URLSearchParams();
let category = (localStorage && localStorage.getItem("selectedSkip") !== null
? '["' + localStorage.getItem("selectedSkip").replace(",", '","') + '"]'
: '["sponsor", "interaction", "selfpromo", "music_offtopic"]');
params.append("category", category);
return await this.fetchJson( return await this.fetchJson(
Constants.BASE_URL + Constants.BASE_URL +
"/sponsors/" + "/sponsors/" +
this.getVideoId() + this.getVideoId() +
"?category=" + "?" + params.toString()
(localStorage && localStorage.getItem("selectedSkip") !== null
? encodeURIComponent('["' + localStorage.getItem("selectedSkip").replace(",", '","') + '"]')
: encodeURIComponent('["sponsor", "interaction", "selfpromo", "music_offtopic"]')),
); );
}, },
fetchComments() { fetchComments() {
@ -191,12 +193,13 @@ export default {
if (this.loading || !this.comments || !this.comments.nextpage) return; if (this.loading || !this.comments || !this.comments.nextpage) return;
if (window.innerHeight + window.scrollY >= this.$refs.comments.offsetHeight - window.innerHeight) { if (window.innerHeight + window.scrollY >= this.$refs.comments.offsetHeight - window.innerHeight) {
this.loading = true; this.loading = true;
let params = new URLSearchParams();
params.append("url", this.comments.nextpage);
this.fetchJson( this.fetchJson(
Constants.BASE_URL + Constants.BASE_URL +
"/nextpage/comments/" + "/nextpage/comments/" +
this.getVideoId() + this.getVideoId() +
"?url=" + "?" + params.toString()
encodeURIComponent(this.comments.nextpage),
).then(json => { ).then(json => {
this.comments.nextpage = json.nextpage; this.comments.nextpage = json.nextpage;
this.loading = false; this.loading = false;