logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe
commit: 92380652feb83c6a4dde5ca3bac35ff4b409fa2d
parent: 17dc7357d5036681b346f745190204e213c0ef8c
Author: Shpuld Shpludson <shp@cock.li>
Date:   Thu,  8 Aug 2019 10:09:07 +0000

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

Add Conversation/Thread Muting

See merge request pleroma/pleroma-fe!876

Diffstat:

Msrc/components/extra_buttons/extra_buttons.js15++++++++++++---
Msrc/components/extra_buttons/extra_buttons.vue14++++++++++++++
Msrc/i18n/en.json4+++-
Msrc/i18n/fi.json9++++++++-
Msrc/modules/statuses.js12++++++++++++
Msrc/services/api/api.service.js14++++++++++++++
Msrc/services/backend_interactor_service/backend_interactor_service.js4++++
Msrc/services/entity_normalizer/entity_normalizer.service.js1+
8 files changed, 68 insertions(+), 5 deletions(-)

diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js @@ -16,6 +16,18 @@ const ExtraButtons = { this.$store.dispatch('unpinStatus', this.status.id) .then(() => this.$emit('onSuccess')) .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: { @@ -30,9 +42,6 @@ const ExtraButtons = { }, canPin () { return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted') - }, - enabled () { - return this.canPin || this.canDelete } } } diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue @@ -10,6 +10,20 @@ <div slot="popover"> <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 v-if="!status.pinned && canPin" v-close-popover class="dropdown-item dropdown-item-icon" diff --git a/src/i18n/en.json b/src/i18n/en.json @@ -508,7 +508,9 @@ "pinned": "Pinned", "delete_confirm": "Do you really want to delete this status?", "reply_to": "Reply to", - "replies_list": "Replies:" + "replies_list": "Replies:", + "mute_conversation": "Mute conversation", + "unmute_conversation": "Unmute conversation" }, "user_card": { "approve": "Approve", diff --git a/src/i18n/fi.json b/src/i18n/fi.json @@ -278,8 +278,15 @@ "status": { "favorites": "Tykkäykset", "repeats": "Toistot", + "delete": "Poista", + "pin": "Kiinnitä profiiliisi", + "unpin": "Poista kiinnitys", + "pinned": "Kiinnitetty", + "delete_confirm": "Haluatko varmasti postaa viestin?", "reply_to": "Vastaus", - "replies_list": "Vastaukset:" + "replies_list": "Vastaukset:", + "mute_conversation": "Hiljennä keskustelu", + "unmute_conversation": "Poista hiljennys" }, "user_card": { "approve": "Hyväksy", diff --git a/src/modules/statuses.js b/src/modules/statuses.js @@ -430,6 +430,10 @@ export const mutations = { const newStatus = state.allStatusesObject[status.id] newStatus.pinned = status.pinned }, + setMuted (state, status) { + const newStatus = state.allStatusesObject[status.id] + newStatus.muted = status.muted + }, setRetweeted (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] @@ -564,6 +568,14 @@ const statuses = { rootState.api.backendInteractor.unpinOwnStatus(statusId) .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) { // Optimistic retweeting... commit('setRetweeted', { status, value: true }) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js @@ -67,6 +67,8 @@ const MASTODON_PROFILE_UPDATE_URL = '/api/v1/accounts/update_credentials' const MASTODON_REPORT_USER_URL = '/api/v1/reports' const MASTODON_PIN_OWN_STATUS = id => `/api/v1/statuses/${id}/pin` 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_USER_SEARCH_URL = '/api/v1/accounts/search' @@ -252,6 +254,16 @@ const unpinOwnStatus = ({ id, credentials }) => { .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 }) => { return fetch(MASTODON_BLOCK_USER_URL(id), { headers: authHeaders(credentials), @@ -920,6 +932,8 @@ const apiService = { unfollowUser, pinOwnStatus, unpinOwnStatus, + muteConversation, + unmuteConversation, blockUser, unblockUser, fetchUser, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js @@ -117,6 +117,8 @@ const backendInteractorService = credentials => { const fetchPinnedStatuses = (id) => apiService.fetchPinnedStatuses({ credentials, id }) const pinOwnStatus = (id) => apiService.pinOwnStatus({ 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 register = (params) => apiService.register({ credentials, params }) @@ -178,6 +180,8 @@ const backendInteractorService = credentials => { fetchPinnedStatuses, pinOwnStatus, unpinOwnStatus, + muteConversation, + unmuteConversation, tagUser, untagUser, addRight, diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js @@ -240,6 +240,7 @@ export const parseStatus = (data) => { output.external_url = data.url output.poll = data.poll output.pinned = data.pinned + output.muted = data.muted } else { output.favorited = data.favorited output.fave_num = data.fave_num