Handle parameters more gracefully with the mixin. (#198)

This commit is contained in:
FireMasterK
2021-06-15 17:07:35 +05:30
committed by GitHub
parent b69cc4c848
commit 546e47df9b
6 changed files with 33 additions and 51 deletions

View File

@@ -144,15 +144,12 @@ export default {
return this.fetchJson(Constants.BASE_URL + "/streams/" + this.getVideoId());
},
async fetchSponsors() {
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"]')),
);
return await this.fetchJson(Constants.BASE_URL + "/sponsors/" + this.getVideoId(), {
category:
localStorage && localStorage.getItem("selectedSkip") !== null
? '["' + localStorage.getItem("selectedSkip").replace(",", '","') + '"]'
: '["sponsor", "interaction", "selfpromo", "music_offtopic"]',
});
},
fetchComments() {
return this.fetchJson(Constants.BASE_URL + "/comments/" + this.getVideoId());
@@ -191,13 +188,9 @@ 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;
this.fetchJson(
Constants.BASE_URL +
"/nextpage/comments/" +
this.getVideoId() +
"?url=" +
encodeURIComponent(this.comments.nextpage),
).then(json => {
this.fetchJson(Constants.BASE_URL + "/nextpage/comments/" + this.getVideoId(), {
url: this.comments.nextpage,
}).then(json => {
this.comments.nextpage = json.nextpage;
this.loading = false;
json.comments.map(comment => this.comments.comments.push(comment));