Add mute/unmute mutations

This commit is contained in:
taehoon 2019-02-24 03:20:11 -05:00
parent 3255950b0e
commit f04cbc8875

View file

@ -108,6 +108,14 @@ export const mutations = {
saveMutes (state, muteIds) { saveMutes (state, muteIds) {
state.currentUser.muteIds = muteIds state.currentUser.muteIds = muteIds
}, },
muteUser (state, id) {
const user = state.usersObject[id]
set(user, 'mastodonMuted', true)
},
unmuteUser (state, id) {
const user = state.usersObject[id]
set(user, 'mastodonMuted', false)
},
setUserForStatus (state, status) { setUserForStatus (state, status) {
status.user = state.usersObject[status.user.id] status.user = state.usersObject[status.user.id]
}, },
@ -200,19 +208,11 @@ const users = {
}, },
muteUser (store, id) { muteUser (store, id) {
return store.rootState.api.backendInteractor.muteUser(id) return store.rootState.api.backendInteractor.muteUser(id)
.then(() => { .then(() => store.commit('muteUser', id))
const user = store.rootState.users.usersObject[id]
set(user, 'mastodonMuted', true)
store.commit('addNewUsers', [user])
})
}, },
unmuteUser (store, id) { unmuteUser (store, id) {
return store.rootState.api.backendInteractor.unmuteUser(id) return store.rootState.api.backendInteractor.unmuteUser(id)
.then(() => { .then(() => store.commit('unmuteUser', id))
const user = store.rootState.users.usersObject[id]
set(user, 'mastodonMuted', false)
store.commit('addNewUsers', [user])
})
}, },
addFriends ({ rootState, commit }, fetchBy) { addFriends ({ rootState, commit }, fetchBy) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {