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 />
|
|
|
|
|
2023-03-13 19:09:07 +05:30
|
|
|
<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" />
|
2023-03-13 19:09:07 +05:30
|
|
|
</LoadingIndicatorPage>
|
2020-11-17 10:45:35 +05:30
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-03-13 19:09:07 +05:30
|
|
|
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 {
|
2021-10-09 00:22:51 +05:30
|
|
|
components: {
|
|
|
|
VideoItem,
|
2023-03-13 19:09:07 +05:30
|
|
|
LoadingIndicatorPage,
|
2021-10-09 00:22:51 +05:30
|
|
|
},
|
2020-11-17 10:45:35 +05:30
|
|
|
data() {
|
|
|
|
return {
|
2021-04-07 17:15:40 +05:30
|
|
|
videos: [],
|
2020-11-17 10:45:35 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2022-11-16 04:05:14 +05:30
|
|
|
if (this.$route.path == "/" && this.getPreferenceString("homepage", "trending") == "feed") return;
|
2021-07-05 18:48:54 +05:30
|
|
|
let region = this.getPreferenceString("region", "US");
|
2021-07-04 23:23:36 +05:30
|
|
|
|
2021-08-22 15:57:09 +05:30
|
|
|
this.fetchTrending(region).then(videos => {
|
|
|
|
this.videos = videos;
|
|
|
|
this.updateWatched(this.videos);
|
|
|
|
});
|
2020-11-17 10:45:35 +05:30
|
|
|
},
|
2021-07-21 16:29:53 +05:30
|
|
|
activated() {
|
2021-08-25 22:00:21 +05:30
|
|
|
document.title = this.$t("titles.trending") + " - Piped";
|
2021-08-22 15:57:09 +05:30
|
|
|
if (this.videos.length > 0) this.updateWatched(this.videos);
|
2023-07-07 21:32:01 +05:30
|
|
|
if (this.$route.path == "/") {
|
|
|
|
let homepage = this.getHomePage(this);
|
|
|
|
if (homepage !== undefined) this.$router.push(homepage);
|
|
|
|
}
|
2021-07-21 16:29:53 +05:30
|
|
|
},
|
2020-11-17 10:45:35 +05:30
|
|
|
methods: {
|
2021-07-04 23:23:36 +05:30
|
|
|
async fetchTrending(region) {
|
2021-07-04 23:56:02 +05:30
|
|
|
return await this.fetchJson(this.apiUrl() + "/trending", {
|
2021-07-04 23:23:36 +05:30
|
|
|
region: region || "US",
|
|
|
|
});
|
2021-04-07 17:15:40 +05:30
|
|
|
},
|
|
|
|
},
|
2020-11-17 10:45:35 +05:30
|
|
|
};
|
|
|
|
</script>
|