Implement domain mutes v2
This commit is contained in:
parent
e3de2964cc
commit
7a013ac393
7 changed files with 265 additions and 49 deletions
|
@ -72,6 +72,16 @@ const showReblogs = (store, userId) => {
|
|||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||
}
|
||||
|
||||
const muteDomain = (store, domain) => {
|
||||
return store.rootState.api.backendInteractor.muteDomain({ domain })
|
||||
.then(() => store.commit('addDomainMute', domain))
|
||||
}
|
||||
|
||||
const unmuteDomain = (store, domain) => {
|
||||
return store.rootState.api.backendInteractor.unmuteDomain({ domain })
|
||||
.then(() => store.commit('removeDomainMute', domain))
|
||||
}
|
||||
|
||||
export const mutations = {
|
||||
setMuted (state, { user: { id }, muted }) {
|
||||
const user = state.usersObject[id]
|
||||
|
@ -177,6 +187,20 @@ export const mutations = {
|
|||
state.currentUser.muteIds.push(muteId)
|
||||
}
|
||||
},
|
||||
saveDomainMutes (state, domainMutes) {
|
||||
state.currentUser.domainMutes = domainMutes
|
||||
},
|
||||
addDomainMute (state, domain) {
|
||||
if (state.currentUser.domainMutes.indexOf(domain) === -1) {
|
||||
state.currentUser.domainMutes.push(domain)
|
||||
}
|
||||
},
|
||||
removeDomainMute (state, domain) {
|
||||
const index = state.currentUser.domainMutes.indexOf(domain)
|
||||
if (index !== -1) {
|
||||
state.currentUser.domainMutes.splice(index, 1)
|
||||
}
|
||||
},
|
||||
setPinnedToUser (state, status) {
|
||||
const user = state.usersObject[status.user.id]
|
||||
const index = user.pinnedStatusIds.indexOf(status.id)
|
||||
|
@ -297,6 +321,25 @@ const users = {
|
|||
unmuteUsers (store, ids = []) {
|
||||
return Promise.all(ids.map(id => unmuteUser(store, id)))
|
||||
},
|
||||
fetchDomainMutes (store) {
|
||||
return store.rootState.api.backendInteractor.fetchDomainMutes()
|
||||
.then((domainMutes) => {
|
||||
store.commit('saveDomainMutes', domainMutes)
|
||||
return domainMutes
|
||||
})
|
||||
},
|
||||
muteDomain (store, domain) {
|
||||
return muteDomain(store, domain)
|
||||
},
|
||||
unmuteDomain (store, domain) {
|
||||
return unmuteDomain(store, domain)
|
||||
},
|
||||
muteDomains (store, domains = []) {
|
||||
return Promise.all(domains.map(domain => muteDomain(store, domain)))
|
||||
},
|
||||
unmuteDomains (store, domain = []) {
|
||||
return Promise.all(domain.map(domain => unmuteDomain(store, domain)))
|
||||
},
|
||||
fetchFriends ({ rootState, commit }, id) {
|
||||
const user = rootState.users.usersObject[id]
|
||||
const maxId = last(user.friendIds)
|
||||
|
@ -460,6 +503,7 @@ const users = {
|
|||
user.credentials = accessToken
|
||||
user.blockIds = []
|
||||
user.muteIds = []
|
||||
user.domainMutes = []
|
||||
commit('setCurrentUser', user)
|
||||
commit('addNewUsers', [user])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue