parent
cb383df517
commit
080786c945
@ -1,68 +0,0 @@
|
|||||||
import UserCard from '../user_card/user_card.vue'
|
|
||||||
|
|
||||||
const FollowList = {
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
loading: false,
|
|
||||||
bottomedOut: false,
|
|
||||||
error: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: ['userId', 'showFollowers'],
|
|
||||||
created () {
|
|
||||||
window.addEventListener('scroll', this.scrollLoad)
|
|
||||||
if (this.entries.length === 0) {
|
|
||||||
this.fetchEntries()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
destroyed () {
|
|
||||||
window.removeEventListener('scroll', this.scrollLoad)
|
|
||||||
this.$store.dispatch('clearFriendsAndFollowers', this.userId)
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
user () {
|
|
||||||
return this.$store.getters.userById(this.userId)
|
|
||||||
},
|
|
||||||
entries () {
|
|
||||||
return this.showFollowers ? this.user.followers : this.user.friends
|
|
||||||
},
|
|
||||||
showFollowsYou () {
|
|
||||||
return !this.showFollowers || (this.showFollowers && this.userId !== this.$store.state.users.currentUser.id)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
fetchEntries () {
|
|
||||||
if (!this.loading) {
|
|
||||||
const command = this.showFollowers ? 'addFollowers' : 'addFriends'
|
|
||||||
this.loading = true
|
|
||||||
this.$store.dispatch(command, this.userId).then(entries => {
|
|
||||||
this.error = false
|
|
||||||
this.loading = false
|
|
||||||
this.bottomedOut = entries.length === 0
|
|
||||||
}).catch(() => {
|
|
||||||
this.error = true
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
scrollLoad (e) {
|
|
||||||
const bodyBRect = document.body.getBoundingClientRect()
|
|
||||||
const height = Math.max(bodyBRect.height, -(bodyBRect.y))
|
|
||||||
if (this.loading === false &&
|
|
||||||
this.bottomedOut === false &&
|
|
||||||
this.$el.offsetHeight > 0 &&
|
|
||||||
(window.innerHeight + window.pageYOffset) >= (height - 750)
|
|
||||||
) {
|
|
||||||
this.fetchEntries()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'user': 'fetchEntries'
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
UserCard
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FollowList
|
|
@ -1,33 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="follow-list">
|
|
||||||
<user-card
|
|
||||||
v-for="entry in entries"
|
|
||||||
:key="entry.id" :user="entry"
|
|
||||||
:noFollowsYou="!showFollowsYou"
|
|
||||||
/>
|
|
||||||
<div class="text-center panel-footer">
|
|
||||||
<a v-if="error" @click="fetchEntries" class="alert error">
|
|
||||||
{{$t('general.generic_error')}}
|
|
||||||
</a>
|
|
||||||
<i v-else-if="loading" class="icon-spin3 animate-spin"/>
|
|
||||||
<span v-else-if="bottomedOut"></span>
|
|
||||||
<a v-else @click="fetchEntries">{{$t('general.more')}}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script src="./follow_list.js"></script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
|
|
||||||
.follow-list {
|
|
||||||
.panel-footer {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
Loading…
Reference in new issue