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) => {
|
|
|
|
const user = {
|
|
|
|
id: 0,
|
|
|
|
name: i.display_name,
|
|
|
|
screen_name: i.acct,
|
2019-06-04 18:04:47 +10:00
|
|
|
profile_image_url: i.avatar || '/images/avi.png',
|
2019-08-16 03:19:49 +10:00
|
|
|
profile_image_url_original: i.avatar || '/images/avi.png',
|
|
|
|
statusnet_profile_url: i.url
|
2019-01-16 13:33:08 +11:00
|
|
|
}
|
|
|
|
this.users.push(user)
|
|
|
|
|
2019-09-04 02:59:28 +10:00
|
|
|
this.$store.state.api.backendInteractor.fetchUser({ id: user.screen_name })
|
2019-01-16 13:33:08 +11:00
|
|
|
.then((externalUser) => {
|
|
|
|
if (!externalUser.error) {
|
|
|
|
this.$store.commit('addNewUsers', [externalUser])
|
|
|
|
user.id = externalUser.id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
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
|