2021-07-17 04:26:41 +05:30
|
|
|
<template>
|
2021-12-27 20:16:26 +05:30
|
|
|
<h1 v-t="'titles.feed'" class="font-bold text-center" />
|
2021-07-17 04:26:41 +05:30
|
|
|
|
2021-12-27 20:16:26 +05:30
|
|
|
<button v-if="authenticated" class="btn" style="margin-right: 0.5rem" @click="exportHandler">
|
2021-10-28 23:25:20 +05:30
|
|
|
<router-link to="/subscriptions"> Subscriptions </router-link>
|
2021-09-04 20:32:59 +05:30
|
|
|
</button>
|
2021-07-17 04:26:41 +05:30
|
|
|
|
2021-09-04 20:32:59 +05:30
|
|
|
<span>
|
2021-09-04 20:54:36 +05:30
|
|
|
<a :href="getRssUrl"><font-awesome-icon icon="rss" style="padding-top: 0.2rem"></font-awesome-icon></a>
|
2021-09-04 20:32:59 +05:30
|
|
|
</span>
|
|
|
|
|
2021-09-12 01:01:01 +05:30
|
|
|
<span class="uk-align-right@m">
|
2021-09-06 03:01:46 +05:30
|
|
|
<label for="ddlSortBy">{{ $t("actions.sort_by") }}</label>
|
2021-10-09 00:22:51 +05:30
|
|
|
<select id="ddlSortBy" v-model="selectedSort" class="uk-select uk-width-auto" @change="onChange()">
|
|
|
|
<option v-t="'actions.most_recent'" value="descending" />
|
|
|
|
<option v-t="'actions.least_recent'" value="ascending" />
|
|
|
|
<option v-t="'actions.channel_name_asc'" value="channel_ascending" />
|
|
|
|
<option v-t="'actions.channel_name_desc'" value="channel_descending" />
|
2021-09-04 20:32:59 +05:30
|
|
|
</select>
|
|
|
|
</span>
|
2021-07-20 01:14:55 +05:30
|
|
|
|
2021-07-17 04:26:41 +05:30
|
|
|
<hr />
|
|
|
|
|
2021-12-27 20:16:22 +05:30
|
|
|
<div class="video-grid">
|
|
|
|
<div v-for="video in videos" :key="video.url" :style="[{ background: backgroundColor }]">
|
2021-07-21 18:02:17 +05:30
|
|
|
<VideoItem :video="video" />
|
2021-07-17 04:26:41 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-07-21 18:02:17 +05:30
|
|
|
import VideoItem from "@/components/VideoItem.vue";
|
|
|
|
|
2021-07-17 04:26:41 +05:30
|
|
|
export default {
|
2021-10-09 00:22:51 +05:30
|
|
|
components: {
|
|
|
|
VideoItem,
|
|
|
|
},
|
2021-07-17 04:26:41 +05:30
|
|
|
data() {
|
|
|
|
return {
|
2021-09-12 01:01:01 +05:30
|
|
|
currentVideoCount: 0,
|
|
|
|
videoStep: 100,
|
|
|
|
videosStore: [],
|
2021-07-17 04:26:41 +05:30
|
|
|
videos: [],
|
2021-07-27 23:34:27 +05:30
|
|
|
selectedSort: "descending",
|
2021-07-17 04:26:41 +05:30
|
|
|
};
|
|
|
|
},
|
2021-10-09 00:22:51 +05:30
|
|
|
computed: {
|
|
|
|
getRssUrl(_this) {
|
|
|
|
return _this.apiUrl() + "/feed/rss?authToken=" + _this.getAuthToken();
|
|
|
|
},
|
|
|
|
},
|
2021-07-17 04:26:41 +05:30
|
|
|
mounted() {
|
2021-08-22 15:57:09 +05:30
|
|
|
this.fetchFeed().then(videos => {
|
2021-09-12 01:01:01 +05:30
|
|
|
this.videosStore = videos;
|
|
|
|
this.loadMoreVideos();
|
2021-08-22 15:57:09 +05:30
|
|
|
this.updateWatched(this.videos);
|
|
|
|
});
|
2021-07-17 04:26:41 +05:30
|
|
|
},
|
2021-07-21 16:29:53 +05:30
|
|
|
activated() {
|
2021-08-26 01:25:30 +05:30
|
|
|
document.title = this.$t("titles.feed") + " - Piped";
|
2021-08-22 15:57:09 +05:30
|
|
|
if (this.videos.length > 0) this.updateWatched(this.videos);
|
2021-09-12 01:01:01 +05:30
|
|
|
window.addEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
|
|
|
deactivated() {
|
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
|
|
|
unmounted() {
|
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
2021-07-21 16:29:53 +05:30
|
|
|
},
|
2021-07-17 04:26:41 +05:30
|
|
|
methods: {
|
|
|
|
async fetchFeed() {
|
|
|
|
return await this.fetchJson(this.apiUrl() + "/feed", {
|
|
|
|
authToken: this.getAuthToken(),
|
|
|
|
});
|
|
|
|
},
|
2021-07-27 23:34:27 +05:30
|
|
|
onChange() {
|
|
|
|
switch (this.selectedSort) {
|
|
|
|
case "ascending":
|
|
|
|
this.videos.sort((a, b) => a.uploaded - b.uploaded);
|
|
|
|
break;
|
|
|
|
case "descending":
|
|
|
|
this.videos.sort((a, b) => b.uploaded - a.uploaded);
|
|
|
|
break;
|
|
|
|
case "channel_ascending":
|
|
|
|
this.videos.sort((a, b) => a.uploaderName.localeCompare(b.uploaderName));
|
|
|
|
break;
|
|
|
|
case "channel_descending":
|
|
|
|
this.videos.sort((a, b) => b.uploaderName.localeCompare(a.uploaderName));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
2021-09-12 01:01:01 +05:30
|
|
|
loadMoreVideos() {
|
|
|
|
this.currentVideoCount = Math.min(this.currentVideoCount + this.videoStep, this.videosStore.length);
|
|
|
|
if (this.videos.length != this.videosStore.length)
|
|
|
|
this.videos = this.videosStore.slice(0, this.currentVideoCount);
|
|
|
|
},
|
|
|
|
handleScroll() {
|
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
|
|
|
this.loadMoreVideos();
|
|
|
|
}
|
|
|
|
},
|
2021-07-17 04:26:41 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|