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

50 lines
1.2 KiB
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) => {
const user = {
id: 0,
name: i.display_name,
screen_name: i.acct,
profile_image_url: i.avatar || '/images/avi.png',
profile_image_url_original: i.avatar || '/images/avi.png'
2019-01-16 02:33:08 +00:00
}
this.users.push(user)
this.$store.state.api.backendInteractor.externalProfile(user.screen_name)
.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) {
apiService.suggestions({credentials: credentials})
.then((reply) => {
this.showWhoToFollow(reply)
})
}
}
}
}
export default WhoToFollow