diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue
index 9a21f404..b44dcaa9 100644
--- a/src/components/user_card_content/user_card_content.vue
+++ b/src/components/user_card_content/user_card_content.vue
@@ -3,6 +3,10 @@
+
Muted
+
+
+
{{user.name}}
@{{user.screen_name}}
@@ -70,6 +74,10 @@
const store = this.$store
store.state.api.backendInteractor.unfollowUser(this.user.id)
.then((unfollowedUser) => store.commit('addNewUsers', [unfollowedUser]))
+ },
+ toggleMute () {
+ const store = this.$store
+ store.commit('setMuted', {user: this.user, muted: !this.user.muted})
}
}
}
diff --git a/src/modules/users.js b/src/modules/users.js
index 8ba365f3..544ca158 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -1,6 +1,7 @@
import timelineFetcher from '../services/timeline_fetcher/timeline_fetcher.service.js'
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import { compact, map, each, find, merge } from 'lodash'
+import { set } from 'vue'
// TODO: Unify with mergeOrAdd in statuses.js
export const mergeOrAdd = (arr, item) => {
@@ -18,6 +19,10 @@ export const mergeOrAdd = (arr, item) => {
}
export const mutations = {
+ setMuted (state, { user: {id}, muted }) {
+ const user = find(state.users, {id})
+ set(user, 'muted', muted)
+ },
setCurrentUser (state, user) {
state.currentUser = user
},
diff --git a/test/unit/specs/modules/users.spec.js b/test/unit/specs/modules/users.spec.js
index 07c71e32..812ba632 100644
--- a/test/unit/specs/modules/users.spec.js
+++ b/test/unit/specs/modules/users.spec.js
@@ -17,4 +17,18 @@ describe('The users module', () => {
expect(state.users).to.eql([user])
expect(state.users[0].name).to.eql('Dude')
})
+
+ it('sets a mute bit on users', () => {
+ const state = cloneDeep(defaultState)
+ const user = { id: 1, name: 'Guy' }
+
+ mutations.addNewUsers(state, [user])
+ mutations.setMuted(state, {user, muted: true})
+
+ expect(user.muted).to.eql(true)
+
+ mutations.setMuted(state, {user, muted: false})
+
+ expect(user.muted).to.eql(false)
+ })
})