diff options
| author | Henry Jameson <me@hjkos.com> | 2020-01-28 20:44:13 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2020-01-28 20:44:13 +0200 |
| commit | f0c4bb1193f71cb93546be7e8f41236c4c192f85 (patch) | |
| tree | 26c35a98a8aa80279a1d8d938e41629a774fda37 /src/modules/users.js | |
| parent | b63e679a31a573c30868477f17322d6ed040af58 (diff) | |
| parent | c54111797ae1058e59931b2d1f12e6ab6a6f96a9 (diff) | |
Merge remote-tracking branch 'upstream/develop' into themes-accent
* upstream/develop: (33 commits)
add emoji reactions to changelog
fix emoji reaction classes broken in develop
review changes
Fix password and email update
remove unnecessary anonymous function
Apply suggestion to src/services/api/api.service.js
remove logs/commented code
remove favs count from react button
remove mock data
change emoji reactions to use new format
Added polyfills for EventTarget (needed for Safari) and CustomEvent (needed for IE)
Fix missing TWKN when logged in, but server is set to private mode.
Fix follower request fetching
Add domain mutes to changelog
Implement domain mutes v2
change changelog to reflect actual release history of frontend
Fix #750 , fix error messages and captcha resetting
Optimize Notifications Rendering
update CHANGELOG
Use last seen notif instead of first unseen notif for sinceId
...
Diffstat (limited to 'src/modules/users.js')
| -rw-r--r-- | src/modules/users.js | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/modules/users.js b/src/modules/users.js index e54588df..ce3e595d 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -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) @@ -373,8 +416,10 @@ const users = { }, addNewNotifications (store, { notifications }) { const users = map(notifications, 'from_profile') + const targetUsers = map(notifications, 'target') const notificationIds = notifications.map(_ => _.id) store.commit('addNewUsers', users) + store.commit('addNewUsers', targetUsers) const notificationsObject = store.rootState.statuses.notifications.idStore const relevantNotifications = Object.entries(notificationsObject) @@ -399,7 +444,9 @@ const users = { let rootState = store.rootState try { - let data = await rootState.api.backendInteractor.register({ ...userInfo }) + let data = await rootState.api.backendInteractor.register( + { params: { ...userInfo } } + ) store.commit('signUpSuccess') store.commit('setToken', data.access_token) store.dispatch('loginUser', data.access_token) @@ -456,6 +503,7 @@ const users = { user.credentials = accessToken user.blockIds = [] user.muteIds = [] + user.domainMutes = [] commit('setCurrentUser', user) commit('addNewUsers', [user]) |
