Complete functionality of BlockCard
This commit is contained in:
parent
0220d3d304
commit
52913d8f87
5 changed files with 39 additions and 6 deletions
|
@ -1,11 +1,18 @@
|
||||||
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
|
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
|
||||||
|
|
||||||
const BlockCard = {
|
const BlockCard = {
|
||||||
props: ['user'],
|
props: ['userId'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
progress: false,
|
progress: false
|
||||||
updated: false
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
user () {
|
||||||
|
return this.$store.getters.userById(this.userId)
|
||||||
|
},
|
||||||
|
blocked () {
|
||||||
|
return this.user.statusnet_blocking
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -14,6 +21,15 @@ const BlockCard = {
|
||||||
methods: {
|
methods: {
|
||||||
unblockUser () {
|
unblockUser () {
|
||||||
this.progress = true
|
this.progress = true
|
||||||
|
this.$store.dispatch('unblockUser', this.user.id).then(() => {
|
||||||
|
this.progress = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
blockUser () {
|
||||||
|
this.progress = true
|
||||||
|
this.$store.dispatch('blockUser', this.user.id).then(() => {
|
||||||
|
this.progress = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<basic-user-card :user="user">
|
<basic-user-card :user="user">
|
||||||
<template slot="secondary-area">
|
<template slot="secondary-area">
|
||||||
<button class="btn btn-default" @click="unblockUser" :disabled="progress">
|
<button class="btn btn-default" @click="unblockUser" :disabled="progress" v-if="blocked">
|
||||||
<template v-if="progress">
|
<template v-if="progress">
|
||||||
{{ $t('user_card.unblock_progress') }}
|
{{ $t('user_card.unblock_progress') }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -9,6 +9,14 @@
|
||||||
{{ $t('user_card.unblock') }}
|
{{ $t('user_card.unblock') }}
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</button>
|
||||||
|
<button class="btn btn-default" @click="blockUser" :disabled="progress" v-else>
|
||||||
|
<template v-if="progress">
|
||||||
|
{{ $t('user_card.block_progress') }}
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
{{ $t('user_card.block') }}
|
||||||
|
</template>
|
||||||
|
</button>
|
||||||
</template>
|
</template>
|
||||||
</basic-user-card>
|
</basic-user-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -9,7 +9,7 @@ import BlockCard from '../block_card/block_card.vue'
|
||||||
import withLoadMore from '../../hocs/with_load_more/with_load_more'
|
import withLoadMore from '../../hocs/with_load_more/with_load_more'
|
||||||
import withList from '../../hocs/with_list/with_list'
|
import withList from '../../hocs/with_list/with_list'
|
||||||
|
|
||||||
const BlockList = withList(BlockCard, entry => ({ user: entry }))
|
const BlockList = withList(BlockCard, entry => ({ userId: entry.id }))
|
||||||
const BlockListWithLoadMore = withLoadMore(
|
const BlockListWithLoadMore = withLoadMore(
|
||||||
BlockList,
|
BlockList,
|
||||||
(props, $store) => $store.dispatch('fetchBlocks'),
|
(props, $store) => $store.dispatch('fetchBlocks'),
|
||||||
|
|
|
@ -368,7 +368,8 @@
|
||||||
"remote_follow": "Remote follow",
|
"remote_follow": "Remote follow",
|
||||||
"statuses": "Statuses",
|
"statuses": "Statuses",
|
||||||
"unblock": "Unblock",
|
"unblock": "Unblock",
|
||||||
"unblock_progress": "Unblocking..."
|
"unblock_progress": "Unblocking...",
|
||||||
|
"block_progress": "Blocking..."
|
||||||
},
|
},
|
||||||
"user_profile": {
|
"user_profile": {
|
||||||
"timeline_title": "User Timeline"
|
"timeline_title": "User Timeline"
|
||||||
|
|
|
@ -154,6 +154,14 @@ const users = {
|
||||||
return blocks
|
return blocks
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
blockUser (store, id) {
|
||||||
|
return store.rootState.api.backendInteractor.blockUser(id)
|
||||||
|
.then((user) => store.commit('addNewUsers', [user]))
|
||||||
|
},
|
||||||
|
unblockUser (store, id) {
|
||||||
|
return store.rootState.api.backendInteractor.unblockUser(id)
|
||||||
|
.then((user) => store.commit('addNewUsers', [user]))
|
||||||
|
},
|
||||||
addFriends ({ rootState, commit }, fetchBy) {
|
addFriends ({ rootState, commit }, fetchBy) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const user = rootState.users.usersObject[fetchBy]
|
const user = rootState.users.usersObject[fetchBy]
|
||||||
|
|
Loading…
Reference in a new issue