Merge branch 'feature/blocks' into 'develop'

Add blocks.

See merge request pleroma/pleroma-fe!130
This commit is contained in:
lambda 2017-11-08 07:02:16 +00:00
commit cdbcf569f8
4 changed files with 54 additions and 0 deletions

View file

@ -46,6 +46,18 @@
</button>
</span>
</div>
<div class='block' v-if='isOtherUser'>
<span v-if='user.statusnet_blocking'>
<button @click="unblockUser" class="base04 base00-background pressed">
{{ $t('user_card.blocked') }}
</button>
</span>
<span v-if='!user.statusnet_blocking'>
<button @click="blockUser" class="base05 base02-background">
{{ $t('user_card.block') }}
</button>
</span>
</div>
</div>
</div>
</div>
@ -113,6 +125,16 @@
store.state.api.backendInteractor.unfollowUser(this.user.id)
.then((unfollowedUser) => store.commit('addNewUsers', [unfollowedUser]))
},
blockUser () {
const store = this.$store
store.state.api.backendInteractor.blockUser(this.user.id)
.then((blockedUser) => store.commit('addNewUsers', [blockedUser]))
},
unblockUser () {
const store = this.$store
store.state.api.backendInteractor.unblockUser(this.user.id)
.then((unblockedUser) => store.commit('addNewUsers', [unblockedUser]))
},
toggleMute () {
const store = this.$store
store.commit('setMuted', {user: this.user, muted: !this.user.muted})

View file

@ -125,6 +125,8 @@ const en = {
follows_you: 'Follows you!',
following: 'Following!',
follow: 'Follow',
blocked: 'Blocked!',
block: 'Block',
statuses: 'Statuses',
mute: 'Mute',
muted: 'Muted',

View file

@ -26,6 +26,8 @@ const BANNER_UPDATE_URL = '/api/account/update_profile_banner.json'
const PROFILE_UPDATE_URL = '/api/account/update_profile.json'
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
const QVITTER_USER_TIMELINE_URL = '/api/qvitter/statuses/user_timeline.json'
const BLOCKING_URL = '/api/blocks/create.json'
const UNBLOCKING_URL = '/api/blocks/destroy.json'
// const USER_URL = '/api/users/show.json'
import { each, map } from 'lodash'
@ -184,6 +186,22 @@ const unfollowUser = ({id, credentials}) => {
}).then((data) => data.json())
}
const blockUser = ({id, credentials}) => {
let url = `${BLOCKING_URL}?user_id=${id}`
return fetch(url, {
headers: authHeaders(credentials),
method: 'POST'
}).then((data) => data.json())
}
const unblockUser = ({id, credentials}) => {
let url = `${UNBLOCKING_URL}?user_id=${id}`
return fetch(url, {
headers: authHeaders(credentials),
method: 'POST'
}).then((data) => data.json())
}
const fetchFriends = ({id, credentials}) => {
let url = `${FRIENDS_URL}?user_id=${id}`
return fetch(url, { headers: authHeaders(credentials) })
@ -343,6 +361,8 @@ const apiService = {
fetchFollowers,
followUser,
unfollowUser,
blockUser,
unblockUser,
favorite,
unfavorite,
retweet,

View file

@ -30,6 +30,14 @@ const backendInteractorService = (credentials) => {
return apiService.unfollowUser({credentials, id})
}
const blockUser = (id) => {
return apiService.blockUser({credentials, id})
}
const unblockUser = (id) => {
return apiService.unblockUser({credentials, id})
}
const startFetching = ({timeline, store, userId = false}) => {
return timelineFetcherService.startFetching({timeline, store, credentials, userId})
}
@ -55,6 +63,8 @@ const backendInteractorService = (credentials) => {
fetchFollowers,
followUser,
unfollowUser,
blockUser,
unblockUser,
fetchAllFollowing,
verifyCredentials: apiService.verifyCredentials,
startFetching,