-
![]()
-
- {{ video.uploader }}
-
-
-
-
- {{ addCommas(video.likes) }}
-
-
- {{ addCommas(video.dislikes) }}
-
-
-
- {{ addCommas(video.views) }} views
-
-
- Uploaded on {{ video.uploadDate }}
-
+
-
Sponsors Segments: {{ sponsors.segments.length }}
-
Loop this Video:
@@ -131,6 +141,8 @@ export default {
selectedAutoPlay: null,
showDesc: true,
comments: null,
+ subscribed: false,
+ channelId: null,
};
},
mounted() {
@@ -184,6 +196,8 @@ export default {
.then(() => {
if (!this.video.error) {
document.title = this.video.title + " - Piped";
+ this.channelId = this.video.uploaderUrl.split("/")[2];
+ this.fetchSubscribedStatus();
this.video.description = this.purifyHTML(
this.video.description
@@ -201,6 +215,36 @@ export default {
async getComments() {
this.fetchComments().then(data => (this.comments = data));
},
+ async fetchSubscribedStatus() {
+ if (!this.channelId) return;
+
+ this.fetchJson(
+ this.apiUrl() + "/subscribed",
+ {
+ channelId: this.channelId,
+ },
+ {
+ headers: {
+ Authorization: this.getAuthToken(),
+ },
+ },
+ ).then(json => {
+ this.subscribed = json.subscribed;
+ });
+ },
+ subscribeHandler() {
+ this.fetchJson(this.apiUrl() + (this.subscribed ? "/unsubscribe" : "/subscribe"), null, {
+ method: "POST",
+ body: JSON.stringify({
+ channelId: this.channelId,
+ }),
+ headers: {
+ Authorization: this.getAuthToken(),
+ "Content-Type": "application/json",
+ },
+ });
+ this.subscribed = !this.subscribed;
+ },
handleScroll() {
if (this.loading || !this.comments || !this.comments.nextpage) return;
if (window.innerHeight + window.scrollY >= this.$refs.comments.offsetHeight - window.innerHeight) {