From 7d60ab322ed996b067242c3f047f90814f9c8f7c Mon Sep 17 00:00:00 2001
From: taehoon
Date: Tue, 7 May 2019 23:36:35 -0400
Subject: [PATCH] use backendInteractor
---
src/modules/statuses.js | 11 ++++++-----
.../backend_interactor_service.js | 11 ++++++++++-
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 527789f8..4c92d4e1 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -524,24 +524,25 @@ const statuses = {
favorite ({ rootState, commit }, status) {
// Optimistic favoriting...
commit('setFavorited', { status, value: true })
- apiService.favorite({ id: status.id, credentials: rootState.users.currentUser.credentials })
+ rootState.api.backendInteractor.favorite(status.id)
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
},
unfavorite ({ rootState, commit }, status) {
- // Optimistic favoriting...
+ // Optimistic unfavoriting...
commit('setFavorited', { status, value: false })
- apiService.unfavorite({ id: status.id, credentials: rootState.users.currentUser.credentials })
+ rootState.api.backendInteractor.unfavorite(status.id)
.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 })
+ rootState.api.backendInteractor.retweet(status.id)
.then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))
},
unretweet ({ rootState, commit }, status) {
+ // Optimistic unretweeting...
commit('setRetweeted', { status, value: false })
- apiService.unretweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
+ rootState.api.backendInteractor.unretweet(status.id)
.then(status => commit('setRetweetedConfirm', { status, user: rootState.users.currentUser }))
},
queueFlush ({ rootState, commit }, { timeline, id }) {
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index 58bb1248..c2b93de4 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -117,6 +117,11 @@ const backendInteractorService = (credentials) => {
const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({id})
const reportUser = (params) => apiService.reportUser({credentials, ...params})
+ const favorite = (id) => apiService.favorite({id, credentials})
+ const unfavorite = (id) => apiService.unfavorite({id, credentials})
+ const retweet = (id) => apiService.retweet({id, credentials})
+ const unretweet = (id) => apiService.unretweet({id, credentials})
+
const backendInteractorServiceInstance = {
fetchStatus,
fetchConversation,
@@ -161,7 +166,11 @@ const backendInteractorService = (credentials) => {
denyUser,
fetchFavoritedByUsers,
fetchRebloggedByUsers,
- reportUser
+ reportUser,
+ favorite,
+ unfavorite,
+ retweet,
+ unretweet
}
return backendInteractorServiceInstance