Add mutes tab

This commit is contained in:
taehoon 2019-02-13 22:04:28 -05:00
parent 09315b2780
commit e91a94ff9c
7 changed files with 99 additions and 6 deletions

View file

@ -0,0 +1,37 @@
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
const MuteCard = {
props: ['userId'],
data () {
return {
progress: false
}
},
computed: {
user () {
return this.$store.getters.userById(this.userId)
},
muted () {
return this.user.muted
}
},
components: {
BasicUserCard
},
methods: {
unmuteUser () {
this.progress = true
this.$store.dispatch('unmuteUser', this.user.id).then(() => {
this.progress = false
})
},
muteUser () {
this.progress = true
this.$store.dispatch('muteUser', this.user.id).then(() => {
this.progress = false
})
}
}
}
export default MuteCard

View file

@ -0,0 +1,24 @@
<template>
<basic-user-card :user="user">
<template slot="secondary-area">
<button class="btn btn-default" @click="unmuteUser" :disabled="progress" v-if="muted">
<template v-if="progress">
{{ $t('user_card.unmute_progress') }}
</template>
<template v-else>
{{ $t('user_card.unmute') }}
</template>
</button>
<button class="btn btn-default" @click="muteUser" :disabled="progress" v-else>
<template v-if="progress">
{{ $t('user_card.mute_progress') }}
</template>
<template v-else>
{{ $t('user_card.mute') }}
</template>
</button>
</template>
</basic-user-card>
</template>
<script src="./mute_card.js"></script>

View file

@ -6,7 +6,7 @@ import ImageCropper from '../image_cropper/image_cropper.vue'
import StyleSwitcher from '../style_switcher/style_switcher.vue'
import fileSizeFormatService from '../../services/file_size_format/file_size_format.js'
import BlockCard from '../block_card/block_card.vue'
import withLoadMore from '../../hocs/with_load_more/with_load_more'
import MuteCard from '../mute_card/mute_card.vue'
import withSubscription from '../../hocs/with_subscription/with_subscription'
import withList from '../../hocs/with_list/with_list'
@ -18,6 +18,14 @@ const BlockListWithSubscription = withSubscription(
'entries'
)
const MuteList = withList(MuteCard, userId => ({ userId }))
const MuteListWithSubscription = withSubscription(
MuteList,
(props, $store) => $store.dispatch('fetchMutes'),
(props, $store) => get($store.state.users.currentUser, 'muteIds', []),
'entries'
)
const UserSettings = {
data () {
return {
@ -55,7 +63,8 @@ const UserSettings = {
StyleSwitcher,
TabSwitcher,
ImageCropper,
'block-list': BlockListWithSubscription
'block-list': BlockListWithSubscription,
'mute-list': MuteListWithSubscription
},
computed: {
user () {

View file

@ -166,6 +166,10 @@
<div :label="$t('settings.blocks_tab')">
<block-list :refresh="true" />
</div>
<div :label="$t('settings.mutes_tab')">
<mute-list :refresh="true" />
</div>
</tab-switcher>
</div>
</div>