2020-11-27 12:16:36 +05:30
|
|
|
<template>
|
2021-06-07 00:17:43 +05:30
|
|
|
<ErrorHandler v-if="channel && channel.error" :message="channel.message" :error="channel.error" />
|
|
|
|
|
|
|
|
<div v-if="channel" v-show="!channel.error">
|
2021-09-01 17:06:00 +05:30
|
|
|
<h1 class="uk-text-center"><img height="48" width="48" class="uk-border-circle" v-bind:src="channel.avatarUrl" />{{ channel.name }}</h1>
|
2021-04-07 17:15:40 +05:30
|
|
|
<img v-if="channel.bannerUrl" v-bind:src="channel.bannerUrl" style="width: 100%" loading="lazy" />
|
2021-07-24 20:47:12 +05:30
|
|
|
<p style="white-space: pre-wrap"><span v-html="purifyHTML(urlify(channel.description))"></span></p>
|
2020-11-27 12:16:36 +05:30
|
|
|
|
2021-07-17 04:26:41 +05:30
|
|
|
<button
|
|
|
|
v-if="authenticated"
|
|
|
|
@click="subscribeHandler"
|
|
|
|
class="uk-button uk-button-small"
|
|
|
|
style="background: #222"
|
|
|
|
type="button"
|
|
|
|
>
|
2021-09-05 18:38:26 +05:30
|
|
|
{{ subscribed ? $t("actions.unsubscribe") : $t("actions.subscribe") }}
|
2021-07-17 04:26:41 +05:30
|
|
|
</button>
|
|
|
|
|
2020-11-27 12:16:36 +05:30
|
|
|
<hr />
|
|
|
|
|
|
|
|
<div class="uk-grid-xl" uk-grid="parallax: 0">
|
|
|
|
<div
|
|
|
|
class="uk-width-1-2 uk-width-1-3@m uk-width-1-4@l uk-width-1-5@xl"
|
2021-06-17 00:44:46 +05:30
|
|
|
v-bind:key="video.url"
|
|
|
|
v-for="video in this.channel.relatedStreams"
|
2020-11-27 12:16:36 +05:30
|
|
|
>
|
2021-06-17 00:44:46 +05:30
|
|
|
<VideoItem :video="video" height="94" width="168" hideChannel />
|
2020-11-27 12:16:36 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-06-07 00:17:43 +05:30
|
|
|
import ErrorHandler from "@/components/ErrorHandler.vue";
|
2021-06-17 00:44:46 +05:30
|
|
|
import VideoItem from "@/components/VideoItem.vue";
|
2020-11-27 12:16:36 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-07 17:15:40 +05:30
|
|
|
channel: null,
|
2021-07-17 04:26:41 +05:30
|
|
|
subscribed: false,
|
2020-11-27 12:16:36 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.getChannelData();
|
2021-07-07 19:48:09 +05:30
|
|
|
},
|
|
|
|
activated() {
|
2021-07-21 16:29:53 +05:30
|
|
|
if (this.channel && !this.channel.error) document.title = this.channel.name + " - Piped";
|
2020-11-27 12:16:36 +05:30
|
|
|
window.addEventListener("scroll", this.handleScroll);
|
2021-08-22 15:57:09 +05:30
|
|
|
if (this.channel && !this.channel.error) this.updateWatched(this.channel.relatedStreams);
|
2020-11-27 12:16:36 +05:30
|
|
|
},
|
2021-07-07 19:48:09 +05:30
|
|
|
deactivated() {
|
2020-11-27 12:16:36 +05:30
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
|
|
|
methods: {
|
2021-07-17 04:26:41 +05:30
|
|
|
async fetchSubscribedStatus() {
|
|
|
|
this.fetchJson(
|
|
|
|
this.apiUrl() + "/subscribed",
|
|
|
|
{
|
|
|
|
channelId: this.channel.id,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
headers: {
|
|
|
|
Authorization: this.getAuthToken(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
).then(json => {
|
|
|
|
this.subscribed = json.subscribed;
|
|
|
|
});
|
|
|
|
},
|
2020-11-27 12:16:36 +05:30
|
|
|
async fetchChannel() {
|
2021-07-04 23:56:02 +05:30
|
|
|
const url = this.apiUrl() + "/" + this.$route.params.path + "/" + this.$route.params.channelId;
|
2021-05-29 00:10:54 +05:30
|
|
|
return await this.fetchJson(url);
|
2020-11-27 12:16:36 +05:30
|
|
|
},
|
|
|
|
async getChannelData() {
|
|
|
|
this.fetchChannel()
|
|
|
|
.then(data => (this.channel = data))
|
2021-06-07 00:17:43 +05:30
|
|
|
.then(() => {
|
2021-07-17 04:26:41 +05:30
|
|
|
if (!this.channel.error) {
|
|
|
|
document.title = this.channel.name + " - Piped";
|
|
|
|
if (this.authenticated) this.fetchSubscribedStatus();
|
2021-08-22 15:57:09 +05:30
|
|
|
this.updateWatched(this.channel.relatedStreams);
|
2021-07-17 04:26:41 +05:30
|
|
|
}
|
2021-06-07 00:17:43 +05:30
|
|
|
});
|
2020-11-27 12:16:36 +05:30
|
|
|
},
|
|
|
|
handleScroll() {
|
2021-06-06 01:05:14 +05:30
|
|
|
if (this.loading || !this.channel || !this.channel.nextpage) return;
|
2021-04-07 17:15:40 +05:30
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
2020-11-27 12:16:36 +05:30
|
|
|
this.loading = true;
|
2021-07-04 23:56:02 +05:30
|
|
|
this.fetchJson(this.apiUrl() + "/nextpage/channel/" + this.channel.id, {
|
2021-06-15 17:07:35 +05:30
|
|
|
nextpage: this.channel.nextpage,
|
|
|
|
}).then(json => {
|
2021-02-24 15:05:41 +05:30
|
|
|
this.channel.nextpage = json.nextpage;
|
|
|
|
this.loading = false;
|
2021-08-22 15:57:09 +05:30
|
|
|
this.updateWatched(json.relatedStreams);
|
2021-04-07 17:15:40 +05:30
|
|
|
json.relatedStreams.map(stream => this.channel.relatedStreams.push(stream));
|
2021-02-24 15:05:41 +05:30
|
|
|
});
|
2020-11-27 12:16:36 +05:30
|
|
|
}
|
2021-04-07 17:15:40 +05:30
|
|
|
},
|
2021-07-17 04:26:41 +05:30
|
|
|
subscribeHandler() {
|
|
|
|
this.fetchJson(this.apiUrl() + (this.subscribed ? "/unsubscribe" : "/subscribe"), null, {
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
|
|
|
channelId: this.channel.id,
|
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
Authorization: this.getAuthToken(),
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this.subscribed = !this.subscribed;
|
|
|
|
},
|
2021-04-07 17:15:40 +05:30
|
|
|
},
|
2021-06-07 00:17:43 +05:30
|
|
|
components: {
|
|
|
|
ErrorHandler,
|
2021-06-17 00:44:46 +05:30
|
|
|
VideoItem,
|
2021-06-07 00:17:43 +05:30
|
|
|
},
|
2020-11-27 12:16:36 +05:30
|
|
|
};
|
|
|
|
</script>
|