2022-03-16 00:31:03 +00:00
|
|
|
<template>
|
2022-03-19 19:31:43 +00:00
|
|
|
<!--
|
|
|
|
* 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" />
|
2022-04-01 01:02:08 +00:00
|
|
|
<div v-for="(section, index) in recommends" :key="index">
|
|
|
|
<horizontal-list-renderer :render="section.contents[0]" />
|
|
|
|
</div>
|
2022-04-24 08:05:36 +00:00
|
|
|
<vid-load-renderer v-if="loading" :count="1" />
|
|
|
|
<observer @intersect="paginate" v-else-if="recommends.length > 0" />
|
2022-03-24 11:47:13 +00:00
|
|
|
</div>
|
2022-03-20 09:50:13 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-03-24 20:46:17 +00:00
|
|
|
import horizontalListRenderer from "~/components/ListRenderers/horizontalListRenderer.vue";
|
|
|
|
import VidLoadRenderer from "~/components/vidLoadRenderer.vue";
|
2022-04-01 01:02:08 +00:00
|
|
|
import Observer from "~/components/observer.vue";
|
2022-03-20 09:50:13 +00:00
|
|
|
export default {
|
2022-04-01 01:02:08 +00:00
|
|
|
components: { horizontalListRenderer, VidLoadRenderer, Observer },
|
2022-05-05 04:28:51 +00:00
|
|
|
data: () => ({
|
|
|
|
loading: false,
|
|
|
|
}),
|
2022-03-24 04:28:57 +00:00
|
|
|
|
|
|
|
computed: {
|
|
|
|
recommends: {
|
|
|
|
get() {
|
2022-05-02 04:42:56 +00:00
|
|
|
return [...this.$store.state.recommendedVideos];
|
2022-03-24 04:28:57 +00:00
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$store.commit("updateRecommendedVideos", val);
|
|
|
|
},
|
|
|
|
},
|
2022-03-20 09:50:13 +00:00
|
|
|
},
|
2022-04-01 01:02:08 +00:00
|
|
|
methods: {
|
|
|
|
paginate() {
|
2022-04-24 08:05:36 +00:00
|
|
|
this.loading = true;
|
|
|
|
const continuationCode = this.recommends[
|
|
|
|
this.recommends.length - 1
|
|
|
|
].continuations.find((element) => element.nextContinuationData)
|
|
|
|
?.nextContinuationData.continuation;
|
|
|
|
if (continuationCode) {
|
2022-04-01 01:02:08 +00:00
|
|
|
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;
|
2022-04-01 01:02:08 +00:00
|
|
|
this.recommends.push(result);
|
|
|
|
});
|
2022-04-24 08:05:36 +00:00
|
|
|
} else {
|
|
|
|
this.loading = false;
|
2022-04-01 01:02:08 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-20 09:50:13 +00:00
|
|
|
mounted() {
|
2022-04-01 01:02:08 +00:00
|
|
|
if (!this.recommends.length) {
|
2022-03-24 04:28:57 +00:00
|
|
|
this.$youtube
|
|
|
|
.recommend()
|
|
|
|
.then((result) => {
|
2022-04-01 01:02:08 +00:00
|
|
|
if (result) this.recommends = [result];
|
2022-03-24 04:28:57 +00:00
|
|
|
})
|
2023-05-03 12:10:09 +00:00
|
|
|
.catch((error) => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
2022-03-24 04:28:57 +00:00
|
|
|
}
|
2022-03-20 09:50:13 +00:00
|
|
|
},
|
|
|
|
};
|
2022-03-21 23:47:11 +00:00
|
|
|
</script>
|
2023-05-08 10:32:52 +00:00
|
|
|
<style>
|
|
|
|
a {
|
|
|
|
-webkit-user-drag: none;
|
|
|
|
}
|
|
|
|
</style>
|