Add users muting.

This commit is contained in:
Roger Braun 2017-02-13 23:22:32 +01:00
parent f9b3f8df84
commit 66ef9f1328
3 changed files with 27 additions and 0 deletions

View file

@ -3,6 +3,10 @@
<div class="base00-background panel-heading text-center" v-bind:style="style">
<div class='user-info'>
<img :src="user.profile_image_url">
<div v-if='user.muted' class='muteinfo'>Muted</div>
<div class='muteinfo'>
<button @click="toggleMute">Mute/Unmute</button>
</div>
<span class="glyphicon glyphicon-user"></span>
<div class='user-name'>{{user.name}}</div>
<div class='user-screen-name'>@{{user.screen_name}}</div>
@ -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})
}
}
}

View file

@ -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
},

View file

@ -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)
})
})