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