diff options
| author | Shpuld Shpludson <shp@cock.li> | 2019-02-28 17:53:40 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2019-02-28 17:53:40 +0000 |
| commit | 88c7c8b1140aaa719e9c9314a8ce9fd04ef3baf1 (patch) | |
| tree | fd18256839bf48bc3c4c0111aa62b8534930e7e8 /src/modules/users.js | |
| parent | dc01f90dde55e2babf58878177308c11aa965006 (diff) | |
| parent | 36460fd3849816af921efdc0b36a6f31f93976ea (diff) | |
Merge branch '398-rewrite-follow-list' into 'develop'
Split UserCard into FollowCard/FollowRequestCard and Rewrite FollowList using HOCs
Closes #398
See merge request pleroma/pleroma-fe!616
Diffstat (limited to 'src/modules/users.js')
| -rw-r--r-- | src/modules/users.js | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/modules/users.js b/src/modules/users.js index eabfe5ae..093af497 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -72,14 +72,20 @@ export const mutations = { }, // Because frontend doesn't have a reason to keep these stuff in memory // outside of viewing someones user profile. - clearFriendsAndFollowers (state, userKey) { - const user = state.usersObject[userKey] + clearFriends (state, userId) { + const user = state.usersObject[userId] if (!user) { return } user.friends = [] - user.followers = [] user.friendsPage = 0 + }, + clearFollowers (state, userId) { + const user = state.usersObject[userId] + if (!user) { + return + } + user.followers = [] user.followersPage = 0 }, addNewUsers (state, users) { @@ -189,20 +195,19 @@ const users = { }) }, addFollowers ({ rootState, commit }, fetchBy) { - return new Promise((resolve, reject) => { - const user = rootState.users.usersObject[fetchBy] - const page = user.followersPage || 1 - rootState.api.backendInteractor.fetchFollowers({ id: user.id, page }) - .then((followers) => { - commit('addFollowers', { id: user.id, followers, page }) - resolve(followers) - }).catch(() => { - reject() - }) - }) + const user = rootState.users.usersObject[fetchBy] + const page = user.followersPage || 1 + return rootState.api.backendInteractor.fetchFollowers({ id: user.id, page }) + .then((followers) => { + commit('addFollowers', { id: user.id, followers, page }) + return followers + }) + }, + clearFriends ({ commit }, userId) { + commit('clearFriends', userId) }, - clearFriendsAndFollowers ({ commit }, userKey) { - commit('clearFriendsAndFollowers', userKey) + clearFollowers ({ commit }, userId) { + commit('clearFollowers', userId) }, registerPushNotifications (store) { const token = store.state.currentUser.credentials |
