2020-11-17 05:15:35 +00:00
|
|
|
<template>
|
2022-07-20 20:20:10 +00:00
|
|
|
<h1 v-t="'titles.trending'" class="font-bold text-center my-4" />
|
2020-11-17 05:15:35 +00:00
|
|
|
|
|
|
|
<hr />
|
|
|
|
|
2021-12-27 14:46:22 +00:00
|
|
|
<div 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" />
|
2020-11-17 05:15:35 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-08 15:46:49 +00:00
|
|
|
import VideoItem from "./VideoItem.vue";
|
2020-11-17 05:15:35 +00:00
|
|
|
|
|
|
|
export default {
|
2021-10-08 18:52:51 +00:00
|
|
|
components: {
|
|
|
|
VideoItem,
|
|
|
|
},
|
2020-11-17 05:15:35 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-07 11:45:40 +00:00
|
|
|
videos: [],
|
2020-11-17 05:15:35 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-07-05 13:18:54 +00:00
|
|
|
let region = this.getPreferenceString("region", "US");
|
2021-07-04 17:53:36 +00:00
|
|
|
|
2021-08-22 10:27:09 +00:00
|
|
|
this.fetchTrending(region).then(videos => {
|
|
|
|
this.videos = videos;
|
|
|
|
this.updateWatched(this.videos);
|
|
|
|
});
|
2020-11-17 05:15:35 +00:00
|
|
|
},
|
2021-07-21 10:59:53 +00:00
|
|
|
activated() {
|
2021-08-25 16:30:21 +00:00
|
|
|
document.title = this.$t("titles.trending") + " - Piped";
|
2021-08-22 10:27:09 +00:00
|
|
|
if (this.videos.length > 0) this.updateWatched(this.videos);
|
2022-07-20 15:52:25 +00:00
|
|
|
if (this.$route.path == "/") {
|
|
|
|
switch (this.getPreferenceString("homepage", "trending")) {
|
|
|
|
case "trending":
|
|
|
|
break;
|
|
|
|
case "feed":
|
|
|
|
this.$router.push("/feed");
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2022-01-31 03:46:06 +00:00
|
|
|
}
|
2021-07-21 10:59:53 +00:00
|
|
|
},
|
2020-11-17 05:15:35 +00:00
|
|
|
methods: {
|
2021-07-04 17:53:36 +00:00
|
|
|
async fetchTrending(region) {
|
2021-07-04 18:26:02 +00:00
|
|
|
return await this.fetchJson(this.apiUrl() + "/trending", {
|
2021-07-04 17:53:36 +00:00
|
|
|
region: region || "US",
|
|
|
|
});
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
|
|
|
},
|
2020-11-17 05:15:35 +00:00
|
|
|
};
|
|
|
|
</script>
|