diff --git a/src/components/block_card/block_card.js b/src/components/block_card/block_card.js index 8788fb62..11fa27b4 100644 --- a/src/components/block_card/block_card.js +++ b/src/components/block_card/block_card.js @@ -1,11 +1,18 @@ import BasicUserCard from '../basic_user_card/basic_user_card.vue' const BlockCard = { - props: ['user'], + props: ['userId'], data () { return { - progress: false, - updated: false + progress: false + } + }, + computed: { + user () { + return this.$store.getters.userById(this.userId) + }, + blocked () { + return this.user.statusnet_blocking } }, components: { @@ -14,6 +21,15 @@ const BlockCard = { methods: { unblockUser () { 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 + }) } } } diff --git a/src/components/block_card/block_card.vue b/src/components/block_card/block_card.vue index 06fc67fc..ed7fe30b 100644 --- a/src/components/block_card/block_card.vue +++ b/src/components/block_card/block_card.vue @@ -1,7 +1,7 @@ diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 3bcecdf4..621dcd4b 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -9,7 +9,7 @@ import BlockCard from '../block_card/block_card.vue' import withLoadMore from '../../hocs/with_load_more/with_load_more' 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( BlockList, (props, $store) => $store.dispatch('fetchBlocks'), diff --git a/src/i18n/en.json b/src/i18n/en.json index 9027803d..eeb95f9c 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -368,7 +368,8 @@ "remote_follow": "Remote follow", "statuses": "Statuses", "unblock": "Unblock", - "unblock_progress": "Unblocking..." + "unblock_progress": "Unblocking...", + "block_progress": "Blocking..." }, "user_profile": { "timeline_title": "User Timeline" diff --git a/src/modules/users.js b/src/modules/users.js index 6ea4e0c9..ce8af68c 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -154,6 +154,14 @@ const users = { 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) { return new Promise((resolve, reject) => { const user = rootState.users.usersObject[fetchBy]