Merge branch 'feat/conversation-muting' into 'develop'

Add Conversation/Thread Muting

See merge request pleroma/pleroma-fe!876
This commit is contained in:
Shpuld Shpludson 2019-08-08 10:09:07 +00:00
commit 92380652fe
8 changed files with 68 additions and 5 deletions

View file

@ -16,6 +16,18 @@ const ExtraButtons = {
this.$store.dispatch('unpinStatus', this.status.id) this.$store.dispatch('unpinStatus', this.status.id)
.then(() => this.$emit('onSuccess')) .then(() => this.$emit('onSuccess'))
.catch(err => this.$emit('onError', err.error.error)) .catch(err => this.$emit('onError', err.error.error))
},
muteConversation () {
this.refreshPopper()
this.$store.dispatch('muteConversation', this.status.id)
.then(() => this.$emit('onSuccess'))
.catch(err => this.$emit('onError', err.error.error))
},
unmuteConversation () {
this.refreshPopper()
this.$store.dispatch('unmuteConversation', this.status.id)
.then(() => this.$emit('onSuccess'))
.catch(err => this.$emit('onError', err.error.error))
} }
}, },
computed: { computed: {
@ -30,9 +42,6 @@ const ExtraButtons = {
}, },
canPin () { canPin () {
return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted') return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted')
},
enabled () {
return this.canPin || this.canDelete
} }
} }
} }

View file

@ -9,6 +9,20 @@
> >
<div slot="popover"> <div slot="popover">
<div class="dropdown-menu"> <div class="dropdown-menu">
<button
v-if="!status.muted"
class="dropdown-item dropdown-item-icon"
@click.prevent="muteConversation"
>
<i class="icon-eye-off" /><span>{{ $t("status.mute_conversation") }}</span>
</button>
<button
v-if="status.muted"
class="dropdown-item dropdown-item-icon"
@click.prevent="unmuteConversation"
>
<i class="icon-eye-off" /><span>{{ $t("status.unmute_conversation") }}</span>
</button>
<button <button
v-if="!status.pinned && canPin" v-if="!status.pinned && canPin"
v-close-popover v-close-popover

View file

@ -508,7 +508,9 @@
"pinned": "Pinned", "pinned": "Pinned",
"delete_confirm": "Do you really want to delete this status?", "delete_confirm": "Do you really want to delete this status?",
"reply_to": "Reply to", "reply_to": "Reply to",
"replies_list": "Replies:" "replies_list": "Replies:",
"mute_conversation": "Mute conversation",
"unmute_conversation": "Unmute conversation"
}, },
"user_card": { "user_card": {
"approve": "Approve", "approve": "Approve",

View file

@ -278,8 +278,15 @@
"status": { "status": {
"favorites": "Tykkäykset", "favorites": "Tykkäykset",
"repeats": "Toistot", "repeats": "Toistot",
"delete": "Poista",
"pin": "Kiinnitä profiiliisi",
"unpin": "Poista kiinnitys",
"pinned": "Kiinnitetty",
"delete_confirm": "Haluatko varmasti postaa viestin?",
"reply_to": "Vastaus", "reply_to": "Vastaus",
"replies_list": "Vastaukset:" "replies_list": "Vastaukset:",
"mute_conversation": "Hiljennä keskustelu",
"unmute_conversation": "Poista hiljennys"
}, },
"user_card": { "user_card": {
"approve": "Hyväksy", "approve": "Hyväksy",

View file

@ -430,6 +430,10 @@ export const mutations = {
const newStatus = state.allStatusesObject[status.id] const newStatus = state.allStatusesObject[status.id]
newStatus.pinned = status.pinned newStatus.pinned = status.pinned
}, },
setMuted (state, status) {
const newStatus = state.allStatusesObject[status.id]
newStatus.muted = status.muted
},
setRetweeted (state, { status, value }) { setRetweeted (state, { status, value }) {
const newStatus = state.allStatusesObject[status.id] const newStatus = state.allStatusesObject[status.id]
@ -564,6 +568,14 @@ const statuses = {
rootState.api.backendInteractor.unpinOwnStatus(statusId) rootState.api.backendInteractor.unpinOwnStatus(statusId)
.then((status) => commit('setPinned', status)) .then((status) => commit('setPinned', status))
}, },
muteConversation ({ rootState, commit }, statusId) {
return rootState.api.backendInteractor.muteConversation(statusId)
.then((status) => commit('setMuted', status))
},
unmuteConversation ({ rootState, commit }, statusId) {
return rootState.api.backendInteractor.unmuteConversation(statusId)
.then((status) => commit('setMuted', status))
},
retweet ({ rootState, commit }, status) { retweet ({ rootState, commit }, status) {
// Optimistic retweeting... // Optimistic retweeting...
commit('setRetweeted', { status, value: true }) commit('setRetweeted', { status, value: true })

View file

@ -67,6 +67,8 @@ const MASTODON_PROFILE_UPDATE_URL = '/api/v1/accounts/update_credentials'
const MASTODON_REPORT_USER_URL = '/api/v1/reports' const MASTODON_REPORT_USER_URL = '/api/v1/reports'
const MASTODON_PIN_OWN_STATUS = id => `/api/v1/statuses/${id}/pin` const MASTODON_PIN_OWN_STATUS = id => `/api/v1/statuses/${id}/pin`
const MASTODON_UNPIN_OWN_STATUS = id => `/api/v1/statuses/${id}/unpin` const MASTODON_UNPIN_OWN_STATUS = id => `/api/v1/statuses/${id}/unpin`
const MASTODON_MUTE_CONVERSATION = id => `/api/v1/statuses/${id}/mute`
const MASTODON_UNMUTE_CONVERSATION = id => `/api/v1/statuses/${id}/unmute`
const MASTODON_SEARCH_2 = `/api/v2/search` const MASTODON_SEARCH_2 = `/api/v2/search`
const MASTODON_USER_SEARCH_URL = '/api/v1/accounts/search' const MASTODON_USER_SEARCH_URL = '/api/v1/accounts/search'
@ -252,6 +254,16 @@ const unpinOwnStatus = ({ id, credentials }) => {
.then((data) => parseStatus(data)) .then((data) => parseStatus(data))
} }
const muteConversation = ({ id, credentials }) => {
return promisedRequest({ url: MASTODON_MUTE_CONVERSATION(id), credentials, method: 'POST' })
.then((data) => parseStatus(data))
}
const unmuteConversation = ({ id, credentials }) => {
return promisedRequest({ url: MASTODON_UNMUTE_CONVERSATION(id), credentials, method: 'POST' })
.then((data) => parseStatus(data))
}
const blockUser = ({ id, credentials }) => { const blockUser = ({ id, credentials }) => {
return fetch(MASTODON_BLOCK_USER_URL(id), { return fetch(MASTODON_BLOCK_USER_URL(id), {
headers: authHeaders(credentials), headers: authHeaders(credentials),
@ -920,6 +932,8 @@ const apiService = {
unfollowUser, unfollowUser,
pinOwnStatus, pinOwnStatus,
unpinOwnStatus, unpinOwnStatus,
muteConversation,
unmuteConversation,
blockUser, blockUser,
unblockUser, unblockUser,
fetchUser, fetchUser,

View file

@ -117,6 +117,8 @@ const backendInteractorService = credentials => {
const fetchPinnedStatuses = (id) => apiService.fetchPinnedStatuses({ credentials, id }) const fetchPinnedStatuses = (id) => apiService.fetchPinnedStatuses({ credentials, id })
const pinOwnStatus = (id) => apiService.pinOwnStatus({ credentials, id }) const pinOwnStatus = (id) => apiService.pinOwnStatus({ credentials, id })
const unpinOwnStatus = (id) => apiService.unpinOwnStatus({ credentials, id }) const unpinOwnStatus = (id) => apiService.unpinOwnStatus({ credentials, id })
const muteConversation = (id) => apiService.muteConversation({ credentials, id })
const unmuteConversation = (id) => apiService.unmuteConversation({ credentials, id })
const getCaptcha = () => apiService.getCaptcha() const getCaptcha = () => apiService.getCaptcha()
const register = (params) => apiService.register({ credentials, params }) const register = (params) => apiService.register({ credentials, params })
@ -178,6 +180,8 @@ const backendInteractorService = credentials => {
fetchPinnedStatuses, fetchPinnedStatuses,
pinOwnStatus, pinOwnStatus,
unpinOwnStatus, unpinOwnStatus,
muteConversation,
unmuteConversation,
tagUser, tagUser,
untagUser, untagUser,
addRight, addRight,

View file

@ -240,6 +240,7 @@ export const parseStatus = (data) => {
output.external_url = data.url output.external_url = data.url
output.poll = data.poll output.poll = data.poll
output.pinned = data.pinned output.pinned = data.pinned
output.muted = data.muted
} else { } else {
output.favorited = data.favorited output.favorited = data.favorited
output.fave_num = data.fave_num output.fave_num = data.fave_num