2020-11-27 06:46:36 +00:00
|
|
|
<template>
|
2021-06-06 18:47:43 +00:00
|
|
|
<ErrorHandler v-if="channel && channel.error" :message="channel.message" :error="channel.error" />
|
|
|
|
|
|
|
|
<div v-if="channel" v-show="!channel.error">
|
2021-04-23 19:11:51 +00:00
|
|
|
<h1 class="uk-text-center"><img height="48" width="48" v-bind:src="channel.avatarUrl" />{{ channel.name }}</h1>
|
2021-04-07 11:45:40 +00:00
|
|
|
<img v-if="channel.bannerUrl" v-bind:src="channel.bannerUrl" style="width: 100%" loading="lazy" />
|
2021-06-06 19:12:03 +00:00
|
|
|
<p v-html="purifyHTML(this.channel.description)" style="white-space: pre"></p>
|
2020-11-27 06:46:36 +00:00
|
|
|
|
|
|
|
<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"
|
|
|
|
v-bind:key="item.url"
|
|
|
|
v-for="item in this.channel.relatedStreams"
|
|
|
|
>
|
2021-04-07 11:45:40 +00:00
|
|
|
<router-link class="uk-link-muted uk-text-justify" v-bind:to="item.url || '/'">
|
2021-04-23 13:26:08 +00:00
|
|
|
<img height="94" width="168" style="width: 100%" v-bind:src="item.thumbnail" loading="lazy" />
|
2020-11-27 06:46:36 +00:00
|
|
|
<a>{{ item.title }}</a>
|
|
|
|
</router-link>
|
|
|
|
<br />
|
|
|
|
<div>
|
|
|
|
<b class="uk-text-small uk-align-left">
|
|
|
|
<font-awesome-icon icon="eye"></font-awesome-icon>
|
2021-06-02 18:43:28 +00:00
|
|
|
{{ numberFormat(item.views) }} views
|
2021-02-24 09:35:41 +00:00
|
|
|
<br />
|
|
|
|
{{ item.uploadedDate }}
|
|
|
|
</b>
|
|
|
|
<b class="uk-text-small uk-align-right">
|
|
|
|
{{ timeFormat(item.duration) }}
|
2020-11-27 06:46:36 +00:00
|
|
|
</b>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Constants from "@/Constants.js";
|
2021-06-06 18:47:43 +00:00
|
|
|
import ErrorHandler from "@/components/ErrorHandler.vue";
|
2020-11-27 06:46:36 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-07 11:45:40 +00:00
|
|
|
channel: null,
|
2020-11-27 06:46:36 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.getChannelData();
|
|
|
|
window.addEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
|
|
|
unmounted() {
|
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async fetchChannel() {
|
2021-05-28 18:40:54 +00:00
|
|
|
const url =
|
|
|
|
Constants.BASE_URL +
|
|
|
|
(this.$route.params.channelId
|
|
|
|
? "/channels/" + this.$route.params.channelId
|
|
|
|
: this.$route.params.channelC
|
|
|
|
? "/c/" + this.$route.params.channelC
|
|
|
|
: "/user/" + this.$route.params.channelUser);
|
|
|
|
return await this.fetchJson(url);
|
2020-11-27 06:46:36 +00:00
|
|
|
},
|
|
|
|
async getChannelData() {
|
|
|
|
this.fetchChannel()
|
|
|
|
.then(data => (this.channel = data))
|
2021-06-06 18:47:43 +00:00
|
|
|
.then(() => {
|
|
|
|
if (!this.channel.error) document.title = this.channel.name + " - Piped";
|
|
|
|
});
|
2020-11-27 06:46:36 +00:00
|
|
|
},
|
|
|
|
handleScroll() {
|
2021-06-05 19:35:14 +00:00
|
|
|
if (this.loading || !this.channel || !this.channel.nextpage) return;
|
2021-04-07 11:45:40 +00:00
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
2020-11-27 06:46:36 +00:00
|
|
|
this.loading = true;
|
2021-02-24 09:35:41 +00:00
|
|
|
this.fetchJson(
|
2020-11-27 06:46:36 +00:00
|
|
|
Constants.BASE_URL +
|
|
|
|
"/nextpage/channels/" +
|
2021-05-28 18:40:54 +00:00
|
|
|
this.channel.id +
|
2021-06-05 19:35:14 +00:00
|
|
|
"?nextpage=" +
|
|
|
|
encodeURIComponent(this.channel.nextpage),
|
2021-02-24 09:35:41 +00:00
|
|
|
).then(json => {
|
|
|
|
this.channel.relatedStreams.concat(json.relatedStreams);
|
|
|
|
this.channel.nextpage = json.nextpage;
|
|
|
|
this.loading = false;
|
2021-04-07 11:45:40 +00:00
|
|
|
json.relatedStreams.map(stream => this.channel.relatedStreams.push(stream));
|
2021-02-24 09:35:41 +00:00
|
|
|
});
|
2020-11-27 06:46:36 +00:00
|
|
|
}
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-06 18:47:43 +00:00
|
|
|
components: {
|
|
|
|
ErrorHandler,
|
|
|
|
},
|
2020-11-27 06:46:36 +00:00
|
|
|
};
|
|
|
|
</script>
|