From a54cf47ba504712369574270ff15af23d3d634f9 Mon Sep 17 00:00:00 2001 From: taehoon Date: Tue, 7 May 2019 23:21:19 -0400 Subject: [PATCH] clean up --- src/modules/statuses.js | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index f384c6d3..527789f8 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -488,8 +488,8 @@ export const mutations = { }, addFavsAndRepeats (state, { id, favoritedByUsers, rebloggedByUsers }) { const newStatus = state.allStatusesObject[id] - newStatus.favoritedBy = favoritedByUsers - newStatus.rebloggedBy = rebloggedByUsers + newStatus.favoritedBy = favoritedByUsers.filter(_ => _) + newStatus.rebloggedBy = rebloggedByUsers.filter(_ => _) } } @@ -525,32 +525,24 @@ const statuses = { // Optimistic favoriting... commit('setFavorited', { status, value: true }) apiService.favorite({ id: status.id, credentials: rootState.users.currentUser.credentials }) - .then(status => { - commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }) - }) + .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser })) }, unfavorite ({ rootState, commit }, status) { // Optimistic favoriting... commit('setFavorited', { status, value: false }) apiService.unfavorite({ id: status.id, credentials: rootState.users.currentUser.credentials }) - .then(status => { - commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }) - }) + .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser })) }, retweet ({ rootState, commit }, status) { // Optimistic retweeting... commit('setRetweeted', { status, value: true }) apiService.retweet({ id: status.id, credentials: rootState.users.currentUser.credentials }) - .then(status => { - commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }) - }) + .then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser })) }, unretweet ({ rootState, commit }, status) { commit('setRetweeted', { status, value: false }) apiService.unretweet({ id: status.id, credentials: rootState.users.currentUser.credentials }) - .then(status => { - commit('setRetweetedConfirm', { status, user: rootState.users.currentUser }) - }) + .then(status => commit('setRetweetedConfirm', { status, user: rootState.users.currentUser })) }, queueFlush ({ rootState, commit }, { timeline, id }) { commit('queueFlush', { timeline, id }) @@ -567,14 +559,7 @@ const statuses = { rootState.api.backendInteractor.fetchFavoritedByUsers(id), rootState.api.backendInteractor.fetchRebloggedByUsers(id) ]).then(([favoritedByUsers, rebloggedByUsers]) => - commit( - 'addFavsAndRepeats', - { - id, - favoritedByUsers: favoritedByUsers.filter(_ => _), - rebloggedByUsers: rebloggedByUsers.filter(_ => _) - } - ) + commit('addFavsAndRepeats', { id, favoritedByUsers, rebloggedByUsers }) ) } },