Skip to content

Commit

Permalink
⚡️ limit shown videos on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
moisout committed Sep 18, 2020
1 parent 11e86c3 commit 1ee5a8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions client/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,36 @@
</div>
<SectionTitle :title="'Popular videos'" :gradient="!userAuthenticated" />
<div class="home-videos-container small">
<VideoEntry v-for="video in videos" :key="video.videoId" :video="video" />
<VideoEntry v-for="video in displayedVideos" :key="video.videoId" :video="video" />
</div>
<BottomNavigation />
<BadgeButton v-if="displayedVideos.length !== videos.length" :click="showMoreVideos">
<LoadMoreIcon />
<p>Show more</p>
</BadgeButton>
</div>
</template>

<script>
import Commons from '@/plugins/commons.js';
import VideoEntry from '@/components/list/VideoEntry';
import BottomNavigation from '@/components/BottomNavigation';
import SectionTitle from '@/components/SectionTitle.vue';
import GradientBackground from '@/components/GradientBackground.vue';
import LoadMoreIcon from 'vue-material-design-icons/Reload';
import Invidious from '@/plugins/services/invidious';
import BadgeButton from '@/components/buttons/BadgeButton';
export default {
name: 'Home',
components: {
VideoEntry,
BottomNavigation,
SectionTitle,
GradientBackground
GradientBackground,
LoadMoreIcon,
BadgeButton
},
data: () => ({
videos: [],
displayedVideos: [],
subscriptions: [],
loading: true,
commons: Commons
Expand All @@ -44,12 +50,16 @@ export default {
this.loadHomepage();
},
methods: {
showMoreVideos() {
this.displayedVideos = this.videos;
},
async loadHomepage() {
const invidious = new Invidious(this.$store.getters['instances/currentInstanceApi']);
await invidious.api
.popular()
.then(response => {
this.videos = response.data;
this.displayedVideos = response.data.slice(0, 8);
})
.catch(error => {
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion client/pages/watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
:loading="commentsContinuationLoading"
>
<LoadMoreIcon />
<p>show more</p>
<p>Show more</p>
</BadgeButton>
</div>
</div>
Expand Down

0 comments on commit 1ee5a8d

Please sign in to comment.