diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f270bfeafb482d3000b42a3302f76232a59d4c7..7164eb2656857bc8e28719c477ad25d1a8bd1cea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added +- Added Report button to status ellipsis menu for easier reporting + ### Fixed - Follows/Followers tabs on user profiles now display the content properly. - Handle punycode in screen names diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js index 395d6685e11bd3b2085441b625d42ff012a0e900..e53c4f773d90938dd8f4310cb48f1bc29d0168ba 100644 --- a/src/components/account_actions/account_actions.js +++ b/src/components/account_actions/account_actions.js @@ -35,7 +35,7 @@ const AccountActions = { this.$store.dispatch('unblockUser', this.user.id) }, reportUser () { - this.$store.dispatch('openUserReportingModal', this.user.id) + this.$store.dispatch('openUserReportingModal', { userId: this.user.id }) }, openChat () { this.$router.push({ diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js index b5b29e8a5a7d2a3fd56e5c7ac1b9c60b8ec63196..dd45b6b9f996e7efab712c67c2da12e9ed2614f7 100644 --- a/src/components/extra_buttons/extra_buttons.js +++ b/src/components/extra_buttons/extra_buttons.js @@ -9,7 +9,8 @@ import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons' import { - faBookmark as faBookmarkReg + faBookmark as faBookmarkReg, + faFlag } from '@fortawesome/free-regular-svg-icons' library.add( @@ -19,7 +20,8 @@ library.add( faEyeSlash, faThumbtack, faShareAlt, - faExternalLinkAlt + faExternalLinkAlt, + faFlag ) const ExtraButtons = { @@ -66,6 +68,9 @@ const ExtraButtons = { this.$store.dispatch('unbookmark', { id: this.status.id }) .then(() => this.$emit('onSuccess')) .catch(err => this.$emit('onError', err.error.error)) + }, + reportStatus () { + this.$store.dispatch('openUserReportingModal', { userId: this.status.user.id, statusIds: [this.status.id] }) } }, computed: { diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue index dc790cad7ec2035e360b0847c904b64401c66057..e845d8fc5aefa98172b207ff4a2d4e6b40da83d3 100644 --- a/src/components/extra_buttons/extra_buttons.vue +++ b/src/components/extra_buttons/extra_buttons.vue @@ -109,6 +109,16 @@ icon="external-link-alt" /><span>{{ $t("status.external_source") }}</span> </a> + <button + class="button-default dropdown-item dropdown-item-icon" + @click.prevent="reportStatus" + @click="close" + > + <FAIcon + fixed-width + :icon="['far', 'flag']" + /><span>{{ $t("user_card.report") }}</span> + </button> </div> </div> <span diff --git a/src/components/user_reporting_modal/user_reporting_modal.js b/src/components/user_reporting_modal/user_reporting_modal.js index 38cf117bf07463af704d9dfee0db300ebbbf5716..5ec4a5dfdeff70b0be397a88088050836e16f9ba 100644 --- a/src/components/user_reporting_modal/user_reporting_modal.js +++ b/src/components/user_reporting_modal/user_reporting_modal.js @@ -48,7 +48,7 @@ const UserReportingModal = { // Reset state this.comment = '' this.forward = false - this.statusIdsToReport = [] + this.statusIdsToReport = this.$store.state.reports.preTickedIds this.processing = false this.error = false }, diff --git a/src/modules/reports.js b/src/modules/reports.js index 904022f1b1f54c96a6a667f3cc6d7c8dab9dfc1d..c6026f38b7e6e5a228d1423e263cefb88d5019de 100644 --- a/src/modules/reports.js +++ b/src/modules/reports.js @@ -4,12 +4,14 @@ const reports = { state: { userId: null, statuses: [], + preTicked: [], modalActivated: false }, mutations: { - openUserReportingModal (state, { userId, statuses }) { + openUserReportingModal (state, { userId, statuses, preTickedIds }) { state.userId = userId state.statuses = statuses + state.preTickedIds = preTickedIds state.modalActivated = true }, closeUserReportingModal (state) { @@ -17,9 +19,15 @@ const reports = { } }, actions: { - openUserReportingModal ({ rootState, commit }, userId) { - const statuses = filter(rootState.statuses.allStatuses, status => status.user.id === userId) - commit('openUserReportingModal', { userId, statuses }) + openUserReportingModal ({ rootState, commit }, { userId, statusIds = [] }) { + const preTickedStatuses = statusIds.map(id => rootState.statuses.allStatusesObject[id]) + const preTickedIds = statusIds + const statuses = preTickedStatuses.concat( + filter(rootState.statuses.allStatuses, + status => status.user.id === userId && !preTickedIds.includes(status.id) + ) + ) + commit('openUserReportingModal', { userId, statuses, preTickedIds }) }, closeUserReportingModal ({ commit }) { commit('closeUserReportingModal') diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 206e628177f79cdca51bc288bbbe6fd450293b5c..625f593ea9b77f05a6214c95e275c59b9a913f09 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -201,7 +201,6 @@ export const parseUser = (data) => { // Convert punycode to unicode if (output.screen_name.includes('@')) { const parts = output.screen_name.split('@') - console.log(parts) let unicodeDomain = punycode.toUnicode(parts[1]) if (unicodeDomain !== parts[1]) { // Add some identifier so users can potentially spot spoofing attempts: