0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-26 05:05:23 +00:00
VueTube/NUXT/pages/home.vue

72 lines
1.8 KiB
Vue
Raw Normal View History

2022-03-16 00:31:03 +00:00
<template>
<!--
* Videos are now polled from '~/components/recommended.vue'
* This is to allow use of "recommended" videos on other pages such as /watch
* -Front
* -->
2022-03-24 11:47:13 +00:00
<div>
<!-- Video Loading Animation -->
2022-04-01 03:03:25 +00:00
<vid-load-renderer v-if="recommends.length == 0" :count="10" />
<div v-for="(section, index) in recommends" :key="index">
<horizontal-list-renderer :render="section.contents[0]" />
</div>
2022-04-01 03:03:25 +00:00
<vid-load-renderer v-if="!loading" :count="1" />
<observer @intersect="paginate" />
2022-03-24 11:47:13 +00:00
</div>
</template>
<script>
2022-03-24 20:46:17 +00:00
import horizontalListRenderer from "~/components/ListRenderers/horizontalListRenderer.vue";
import VidLoadRenderer from "~/components/vidLoadRenderer.vue";
import Observer from "~/components/observer.vue";
export default {
components: { horizontalListRenderer, VidLoadRenderer, Observer },
2022-03-24 04:28:57 +00:00
computed: {
recommends: {
get() {
return this.$store.state.recommendedVideos;
},
set(val) {
this.$store.commit("updateRecommendedVideos", val);
},
},
},
2022-04-01 03:03:25 +00:00
data: {
loading: false,
},
methods: {
paginate() {
if (this.recommends) {
2022-04-01 03:03:25 +00:00
this.loading = true;
this.$youtube
.recommendContinuation(
this.recommends[this.recommends.length - 1].continuations.find(
(element) => element.nextContinuationData
).nextContinuationData.continuation,
"browse"
)
.then((result) => {
2022-04-01 03:03:25 +00:00
this.loading = false;
this.recommends.push(result);
});
}
},
},
mounted() {
if (!this.recommends.length) {
2022-03-24 04:28:57 +00:00
this.$youtube
.recommend()
.then((result) => {
if (result) this.recommends = [result];
2022-03-24 04:28:57 +00:00
})
.catch((error) => this.$logger("Home Page", error, true));
}
},
};
2022-03-21 23:47:11 +00:00
</script>