Backend Interactor service overhaul, removed the need for copypasting
This commit is contained in:
parent
41d2fa2fd6
commit
ddb6fb9217
10 changed files with 55 additions and 256 deletions
|
@ -32,7 +32,7 @@ const getNotificationPermission = () => {
|
|||
}
|
||||
|
||||
const blockUser = (store, id) => {
|
||||
return store.rootState.api.backendInteractor.blockUser(id)
|
||||
return store.rootState.api.backendInteractor.blockUser({ id })
|
||||
.then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
store.commit('addBlockId', id)
|
||||
|
@ -43,12 +43,12 @@ const blockUser = (store, id) => {
|
|||
}
|
||||
|
||||
const unblockUser = (store, id) => {
|
||||
return store.rootState.api.backendInteractor.unblockUser(id)
|
||||
return store.rootState.api.backendInteractor.unblockUser({ id })
|
||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||
}
|
||||
|
||||
const muteUser = (store, id) => {
|
||||
return store.rootState.api.backendInteractor.muteUser(id)
|
||||
return store.rootState.api.backendInteractor.muteUser({ id })
|
||||
.then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
store.commit('addMuteId', id)
|
||||
|
@ -56,7 +56,7 @@ const muteUser = (store, id) => {
|
|||
}
|
||||
|
||||
const unmuteUser = (store, id) => {
|
||||
return store.rootState.api.backendInteractor.unmuteUser(id)
|
||||
return store.rootState.api.backendInteractor.unmuteUser({ id })
|
||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||
}
|
||||
|
||||
|
@ -324,11 +324,11 @@ const users = {
|
|||
commit('clearFollowers', userId)
|
||||
},
|
||||
subscribeUser ({ rootState, commit }, id) {
|
||||
return rootState.api.backendInteractor.subscribeUser(id)
|
||||
return rootState.api.backendInteractor.subscribeUser({ id })
|
||||
.then((relationship) => commit('updateUserRelationship', [relationship]))
|
||||
},
|
||||
unsubscribeUser ({ rootState, commit }, id) {
|
||||
return rootState.api.backendInteractor.unsubscribeUser(id)
|
||||
return rootState.api.backendInteractor.unsubscribeUser({ id })
|
||||
.then((relationship) => commit('updateUserRelationship', [relationship]))
|
||||
},
|
||||
registerPushNotifications (store) {
|
||||
|
@ -382,7 +382,7 @@ const users = {
|
|||
})
|
||||
},
|
||||
searchUsers (store, query) {
|
||||
return store.rootState.api.backendInteractor.searchUsers(query)
|
||||
return store.rootState.api.backendInteractor.searchUsers({ query })
|
||||
.then((users) => {
|
||||
store.commit('addNewUsers', users)
|
||||
return users
|
||||
|
@ -394,7 +394,7 @@ const users = {
|
|||
let rootState = store.rootState
|
||||
|
||||
try {
|
||||
let data = await rootState.api.backendInteractor.register(userInfo)
|
||||
let data = await rootState.api.backendInteractor.register({ ...userInfo })
|
||||
store.commit('signUpSuccess')
|
||||
store.commit('setToken', data.access_token)
|
||||
store.dispatch('loginUser', data.access_token)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue