mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Use URLSearchParams
This commit is contained in:
parent
b69cc4c848
commit
818a8709ce
5 changed files with 30 additions and 22 deletions
|
@ -74,12 +74,13 @@ export default {
|
|||
if (this.loading || !this.channel || !this.channel.nextpage) return;
|
||||
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
||||
this.loading = true;
|
||||
let params = new URLSearchParams();
|
||||
params.append("nextpage", this.channel.nextpage);
|
||||
this.fetchJson(
|
||||
Constants.BASE_URL +
|
||||
"/nextpage/channels/" +
|
||||
this.channel.id +
|
||||
"?nextpage=" +
|
||||
encodeURIComponent(this.channel.nextpage),
|
||||
"?" + params.toString()
|
||||
).then(json => {
|
||||
this.channel.relatedStreams.concat(json.relatedStreams);
|
||||
this.channel.nextpage = json.nextpage;
|
||||
|
|
|
@ -74,12 +74,14 @@ export default {
|
|||
if (this.loading || !this.playlist || !this.playlist.nextpage) return;
|
||||
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
||||
this.loading = true;
|
||||
let params = new URLSearchParams();
|
||||
params.append("nextpage", this.playlist.nextpage);
|
||||
this.fetchJson(
|
||||
Constants.BASE_URL +
|
||||
"/nextpage/playlists/" +
|
||||
this.$route.query.list +
|
||||
"?nextpage=" +
|
||||
encodeURIComponent(this.playlist.nextpage),
|
||||
"?" +
|
||||
params.toString()
|
||||
).then(json => {
|
||||
this.playlist.relatedStreams.concat(json.relatedStreams);
|
||||
this.playlist.nextpage = json.nextpage;
|
||||
|
|
|
@ -100,12 +100,13 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async fetchResults() {
|
||||
let params = new URLSearchParams();
|
||||
params.append("q", this.$route.query.search_query);
|
||||
params.append("filter", this.selectedFilter)
|
||||
return await await this.fetchJson(
|
||||
Constants.BASE_URL +
|
||||
"/search?q=" +
|
||||
encodeURIComponent(this.$route.query.search_query) +
|
||||
"&filter=" +
|
||||
this.selectedFilter,
|
||||
"/search?" +
|
||||
params.toString()
|
||||
);
|
||||
},
|
||||
async updateResults() {
|
||||
|
@ -116,15 +117,14 @@ export default {
|
|||
if (this.loading || !this.results || !this.results.nextpage) return;
|
||||
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
||||
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(
|
||||
Constants.BASE_URL +
|
||||
"/nextpage/search" +
|
||||
"?nextpage=" +
|
||||
encodeURIComponent(this.results.nextpage) +
|
||||
"&q=" +
|
||||
encodeURIComponent(this.$route.query.search_query) +
|
||||
"&filter=" +
|
||||
this.selectedFilter,
|
||||
"/nextpage/search?" +
|
||||
params.toString()
|
||||
).then(json => {
|
||||
this.results.nextpage = json.nextpage;
|
||||
this.results.id = json.id;
|
||||
|
|
|
@ -49,8 +49,10 @@ export default {
|
|||
}
|
||||
},
|
||||
async refreshSuggestions() {
|
||||
let params = new URLSearchParams();
|
||||
params.append("query", this.searchText);
|
||||
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.setSelected(0);
|
||||
|
|
|
@ -144,14 +144,16 @@ export default {
|
|||
return this.fetchJson(Constants.BASE_URL + "/streams/" + this.getVideoId());
|
||||
},
|
||||
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(
|
||||
Constants.BASE_URL +
|
||||
"/sponsors/" +
|
||||
this.getVideoId() +
|
||||
"?category=" +
|
||||
(localStorage && localStorage.getItem("selectedSkip") !== null
|
||||
? encodeURIComponent('["' + localStorage.getItem("selectedSkip").replace(",", '","') + '"]')
|
||||
: encodeURIComponent('["sponsor", "interaction", "selfpromo", "music_offtopic"]')),
|
||||
"?" + params.toString()
|
||||
);
|
||||
},
|
||||
fetchComments() {
|
||||
|
@ -191,12 +193,13 @@ export default {
|
|||
if (this.loading || !this.comments || !this.comments.nextpage) return;
|
||||
if (window.innerHeight + window.scrollY >= this.$refs.comments.offsetHeight - window.innerHeight) {
|
||||
this.loading = true;
|
||||
let params = new URLSearchParams();
|
||||
params.append("url", this.comments.nextpage);
|
||||
this.fetchJson(
|
||||
Constants.BASE_URL +
|
||||
"/nextpage/comments/" +
|
||||
this.getVideoId() +
|
||||
"?url=" +
|
||||
encodeURIComponent(this.comments.nextpage),
|
||||
"?" + params.toString()
|
||||
).then(json => {
|
||||
this.comments.nextpage = json.nextpage;
|
||||
this.loading = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue