1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-17 07:40:27 +05:30
Piped/src/components/TrendingPage.vue

48 lines
1.3 KiB
Vue
Raw Normal View History

2020-11-17 10:45:35 +05:30
<template>
2022-07-21 01:50:10 +05:30
<h1 v-t="'titles.trending'" class="font-bold text-center my-4" />
2020-11-17 10:45:35 +05:30
<hr />
<LoadingIndicatorPage :show-content="videos.length != 0" class="video-grid">
2022-11-01 17:42:54 +05:30
<VideoItem v-for="video in videos" :key="video.url" :item="video" height="118" width="210" />
</LoadingIndicatorPage>
2020-11-17 10:45:35 +05:30
</template>
<script>
import LoadingIndicatorPage from "./LoadingIndicatorPage.vue";
2022-04-08 21:16:49 +05:30
import VideoItem from "./VideoItem.vue";
2020-11-17 10:45:35 +05:30
export default {
components: {
VideoItem,
LoadingIndicatorPage,
},
2020-11-17 10:45:35 +05:30
data() {
return {
videos: [],
2020-11-17 10:45:35 +05:30
};
},
mounted() {
if (this.$route.path == "/" && this.getPreferenceString("homepage", "trending") == "feed") return;
let region = this.getPreferenceString("region", "US");
this.fetchTrending(region).then(videos => {
this.videos = videos;
this.updateWatched(this.videos);
});
2020-11-17 10:45:35 +05:30
},
activated() {
document.title = this.$t("titles.trending") + " - Piped";
if (this.videos.length > 0) this.updateWatched(this.videos);
if (this.$route.path == "/") this.openHomePage(this);
},
2020-11-17 10:45:35 +05:30
methods: {
async fetchTrending(region) {
return await this.fetchJson(this.apiUrl() + "/trending", {
region: region || "US",
});
},
},
2020-11-17 10:45:35 +05:30
};
</script>