akkoma-fe/src/components/who_to_follow/who_to_follow.js

41 lines
965 B
JavaScript
Raw Normal View History

2019-01-16 02:33:08 +00:00
import apiService from '../../services/api/api.service.js'
import FollowCard from '../follow_card/follow_card.vue'
2019-01-16 02:33:08 +00:00
const WhoToFollow = {
components: {
FollowCard
2019-01-16 02:33:08 +00:00
},
data () {
return {
users: []
}
},
mounted () {
this.getWhoToFollow()
},
methods: {
showWhoToFollow (reply) {
reply.forEach((i, index) => {
this.$store.state.api.backendInteractor.fetchUser({ id: i.acct })
2019-01-16 02:33:08 +00:00
.then((externalUser) => {
if (!externalUser.error) {
this.$store.commit('addNewUsers', [externalUser])
this.users.push(externalUser)
2019-01-16 02:33:08 +00:00
}
})
})
},
getWhoToFollow () {
const credentials = this.$store.state.users.currentUser.credentials
if (credentials) {
2019-07-05 07:02:14 +00:00
apiService.suggestions({ credentials: credentials })
2019-01-16 02:33:08 +00:00
.then((reply) => {
this.showWhoToFollow(reply)
})
}
}
}
}
export default WhoToFollow