diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-12-03 10:02:46 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-12-03 11:41:04 +0100 |
commit | 1ad1dd0461ef86136ea948525cfe6cffe79e9011 (patch) | |
tree | fa6c4807bafaf6092274e3169ce4ee80d5ddc611 /src/store | |
parent | d16b1770fe7931b82cc65d7e81a9ccbebd108d5f (diff) |
Fetch followers/following list on profile view
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/account.js | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/store/account.js b/src/store/account.js index 6af8ab14..b423a369 100644 --- a/src/store/account.js +++ b/src/store/account.js @@ -24,22 +24,54 @@ import axios from 'nextcloud-axios' import Vue from 'vue' const state = { - accounts: {} + accounts: {}, + accountsFollowers: {}, + accountsFollowing: {} } const mutations = { addAccount(state, { uid, data }) { Vue.set(state.accounts, uid, data) + }, + addFollowers(state, { uid, data }) { + let users = [] + for (var index in data) { + users.push(data[index].actor_info) + } + Vue.set(state.accountsFollowers, uid, users) + }, + addFollowing(state, { uid, data }) { + let users = [] + for (var index in data) { + users.push(data[index].actor_info) + } + Vue.set(state.accountsFollowing, uid, users) } } const getters = { getAccount(state) { return (uid) => state.accounts[uid] + }, + getAccountFollowers(state) { + return (uid) => state.accountsFollowers[uid] + }, + getAccountFollowing(state) { + return (uid) => state.accountsFollowing[uid] } } const actions = { fetchAccountInfo(context, uid) { - axios.get(OC.generateUrl('apps/social/local/account/' + uid)).then((response) => { - context.commit('addAccount', { uid: uid, data: response.data }) + axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/info`)).then((response) => { + context.commit('addAccount', { uid: uid, data: response.data.result.account }) + }) + }, + fetchAccountFollowers(context, uid) { + axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/followers`)).then((response) => { + context.commit('addFollowers', { uid: uid, data: response.data.result }) + }) + }, + fetchAccountFollowing(context, uid) { + axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/following`)).then((response) => { + context.commit('addFollowing', { uid: uid, data: response.data.result }) }) } } |