2018-03-09 07:21:25 +01:00
|
|
|
<template>
|
|
|
|
<div id="home">
|
2018-03-20 14:21:16 +01:00
|
|
|
<div class="home-timeline" v-for="(message, index) in timeline" v-bind:key="index">
|
2018-03-12 08:42:05 +01:00
|
|
|
<toot :message="message"></toot>
|
|
|
|
</div>
|
2018-03-27 08:33:20 +02:00
|
|
|
<div class="loading-card" v-loading="lazyLoading">
|
|
|
|
</div>
|
2018-03-09 07:21:25 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-03-12 08:42:05 +01:00
|
|
|
import { mapState } from 'vuex'
|
2018-03-12 15:13:55 +01:00
|
|
|
import Toot from './Cards/Toot'
|
2018-03-12 08:42:05 +01:00
|
|
|
|
2018-03-09 07:21:25 +01:00
|
|
|
export default {
|
2018-03-12 08:42:05 +01:00
|
|
|
name: 'home',
|
|
|
|
components: { Toot },
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
2018-03-27 08:33:20 +02:00
|
|
|
timeline: state => state.TimelineSpace.homeTimeline,
|
|
|
|
lazyLoading: state => state.TimelineSpace.Home.lazyLoading
|
2018-03-12 08:42:05 +01:00
|
|
|
})
|
2018-03-26 14:58:58 +02:00
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
this.$store.commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', false)
|
2018-03-27 08:33:20 +02:00
|
|
|
window.addEventListener('scroll', this.onScroll)
|
2018-03-26 14:58:58 +02:00
|
|
|
},
|
|
|
|
beforeUpdate () {
|
|
|
|
if (this.$store.state.TimelineSpace.SideMenu.unreadHomeTimeline) {
|
|
|
|
this.$store.commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', false)
|
|
|
|
}
|
2018-03-27 06:58:20 +02:00
|
|
|
},
|
|
|
|
destroyed () {
|
|
|
|
this.$store.commit('TimelineSpace/archiveHomeTimeline')
|
2018-03-27 08:33:20 +02:00
|
|
|
window.removeEventListener('scroll', this.onScroll)
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onScroll (event) {
|
|
|
|
if (((document.documentElement.clientHeight + event.target.defaultView.scrollY) >= document.getElementById('home').clientHeight - 10) && !this.lazyloading) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Home/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
|
|
|
}
|
|
|
|
}
|
2018-03-12 08:42:05 +01:00
|
|
|
}
|
2018-03-09 07:21:25 +01:00
|
|
|
}
|
|
|
|
</script>
|
2018-03-12 08:42:05 +01:00
|
|
|
|
2018-03-27 08:33:20 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.loading-card {
|
|
|
|
background-color: #ffffff;
|
|
|
|
height: 60px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loading-card:empty {
|
|
|
|
height: 0;
|
|
|
|
}
|
|
|
|
</style>
|