From 4ab2ddb03cdd3740eb18d8c7d85de80e176db29f Mon Sep 17 00:00:00 2001 From: Brenden Bice Date: Tue, 2 Apr 2019 11:04:39 -0400 Subject: [PATCH] improve code quality --- src/components/avatar_list/avatar_list.vue | 4 ++-- src/components/conversation/conversation.js | 16 ++-------------- src/modules/statuses.js | 8 ++++---- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/components/avatar_list/avatar_list.vue b/src/components/avatar_list/avatar_list.vue index 56ca12a2..a3bed515 100644 --- a/src/components/avatar_list/avatar_list.vue +++ b/src/components/avatar_list/avatar_list.vue @@ -1,7 +1,7 @@ diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 18635aa1..851d30e9 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -153,22 +153,10 @@ const conversation = { } }, fetchFavouritedByUsers (id) { - this.$store.state.api.backendInteractor.fetchFavouritedByUsers({id}).then((response) => { - const favoritedByUsers = response.map(item => ({ - src: item.avatar_static, - name: item.display_name - })) - this.$store.dispatch('addFavoritedByUsers', { favoritedByUsers, id }) - }) + this.$store.dispatch('fetchFavouritedByUsers', { id }) }, fetchRebloggedByUsers (id) { - this.$store.state.api.backendInteractor.fetchRebloggedByUsers({id}).then((response) => { - const rebloggedByUsers = response.map(item => ({ - src: item.avatar_static, - name: item.display_name - })) - this.$store.dispatch('addRebloggedByUsers', { rebloggedByUsers, id }) - }) + this.$store.dispatch('fetchRebloggedByUsers', { id }) } } } diff --git a/src/modules/statuses.js b/src/modules/statuses.js index c749e60f..2cfc3ff1 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -537,11 +537,11 @@ const statuses = { credentials: rootState.users.currentUser.credentials }) }, - addFavoritedByUsers ({ rootState, commit }, { favoritedByUsers, id }) { - commit('addFavoritedByUsers', { favoritedByUsers, id }) + fetchFavouritedByUsers ({ rootState, commit }, { id }) { + rootState.api.backendInteractor.fetchFavouritedByUsers({id}).then((favoritedByUsers) => commit('addFavoritedByUsers', { favoritedByUsers, id })) }, - addRebloggedByUsers ({ rootState, commit }, { rebloggedByUsers, id }) { - commit('addRebloggedByUsers', { rebloggedByUsers, id }) + fetchRebloggedByUsers ({ rootState, commit }, { id }) { + rootState.api.backendInteractor.fetchRebloggedByUsers({id}).then((rebloggedByUsers) => commit('addRebloggedByUsers', { rebloggedByUsers, id })) } }, mutations