diff --git a/src/components/WatchVideo.vue b/src/components/WatchVideo.vue index dcb6087e..797ba792 100644 --- a/src/components/WatchVideo.vue +++ b/src/components/WatchVideo.vue @@ -10,48 +10,52 @@ :selectedAutoPlay="selectedAutoPlay" :selectedAutoLoop="selectedAutoLoop" /> -

{{ video.title }}

- -
-
- - - {{ video.uploader }} - - -
- - {{ addCommas(video.likes) }} -   - - {{ addCommas(video.dislikes) }} -
-
- - {{ addCommas(video.views) }} views -
-
- Uploaded on {{ video.uploadDate }} -
+
{{ video.title }}
+ +
+
{{ addCommas(video.views) }} views
+
{{ video.uploadDate }}
+
+
+ + {{ addCommas(video.likes) }}
- -
- Watch on +
+ + {{ addCommas(video.dislikes) }}
+ + + Watch on + +
+ +
+ + + {{ video.uploader }} + +
+

- {{ showDesc ? "+" : "-" }} + {{ showDesc ? "Minimize Description" : "Show Description" }}

+
Sponsors Segments: {{ sponsors.segments.length }}
- Sponsors Segments: {{ sponsors.segments.length }} -
Loop this Video:  @@ -131,6 +135,8 @@ export default { selectedAutoPlay: null, showDesc: true, comments: null, + subscribed: false, + channelId: null, }; }, mounted() { @@ -184,6 +190,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 +209,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) {