Piped/src/components/TrendingPage.vue

52 lines
1.5 KiB
Vue
Raw Normal View History

2020-11-17 05:15:35 +00:00
<template>
<h1 v-t="'titles.trending'" class="my-4 text-center font-bold" />
2020-11-17 05:15:35 +00:00
<hr />
<LoadingIndicatorPage :show-content="videos.length != 0" class="video-grid">
2022-11-01 12:12:54 +00:00
<VideoItem v-for="video in videos" :key="video.url" :item="video" height="118" width="210" />
</LoadingIndicatorPage>
2020-11-17 05:15:35 +00:00
</template>
<script>
import LoadingIndicatorPage from "./LoadingIndicatorPage.vue";
2022-04-08 15:46:49 +00:00
import VideoItem from "./VideoItem.vue";
2020-11-17 05:15:35 +00:00
export default {
components: {
VideoItem,
LoadingIndicatorPage,
},
2020-11-17 05:15:35 +00:00
data() {
return {
videos: [],
2020-11-17 05:15:35 +00:00
};
},
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);
this.fetchDeArrowContent(this.videos);
});
2020-11-17 05:15:35 +00:00
},
activated() {
document.title = this.$t("titles.trending") + " - Piped";
if (this.videos.length > 0) this.updateWatched(this.videos);
if (this.$route.path == "/") {
let homepage = this.getHomePage(this);
if (homepage !== undefined) this.$router.push(homepage);
}
},
2020-11-17 05:15:35 +00:00
methods: {
async fetchTrending(region) {
return await this.fetchJson(this.apiUrl() + "/trending", {
region: region || "US",
});
},
},
2020-11-17 05:15:35 +00:00
};
</script>