From e2cc6d4cf874d1160e3a747bbd1ca2741d556f00 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sun, 18 Jul 2021 12:47:39 -0500 Subject: [PATCH] Give the video meta data section a bit of breathing room (#273) * Give the video meta data section a bit of breathing room * Apply linter. Co-authored-by: FireMasterK <20838718+FireMasterK@users.noreply.github.com> --- src/components/WatchVideo.vue | 104 ++++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 30 deletions(-) diff --git a/src/components/WatchVideo.vue b/src/components/WatchVideo.vue index dcb6087e..094e391f 100644 --- a/src/components/WatchVideo.vue +++ b/src/components/WatchVideo.vue @@ -10,48 +10,58 @@ :selectedAutoPlay="selectedAutoPlay" :selectedAutoLoop="selectedAutoLoop" /> -

{{ video.title }}

+
{{ video.title }}
-
-
- - - {{ video.uploader }} - - -
- - {{ addCommas(video.likes) }} -   - - {{ addCommas(video.dislikes) }} -
-
- - {{ addCommas(video.views) }} views -
-
- Uploaded on {{ video.uploadDate }} -
+
+
{{ 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 +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) {