From 3822a73a49f82c71217bc610720324a4303626cf Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Mon, 1 Feb 2021 12:55:23 +0200 Subject: [PATCH] Fix report modal not working, add include_types --- .../user_reporting_modal/user_reporting_modal.js | 12 +++++++----- src/modules/reports.js | 2 +- src/services/api/api.service.js | 8 +++++++- .../notifications_fetcher.service.js | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/components/user_reporting_modal/user_reporting_modal.js b/src/components/user_reporting_modal/user_reporting_modal.js index 8d171b2d58..85ffc6616a 100644 --- a/src/components/user_reporting_modal/user_reporting_modal.js +++ b/src/components/user_reporting_modal/user_reporting_modal.js @@ -1,4 +1,3 @@ - import Status from '../status/status.vue' import List from '../list/list.vue' import Checkbox from '../checkbox/checkbox.vue' @@ -21,14 +20,17 @@ const UserReportingModal = { } }, computed: { + reportModal () { + return this.$store.state.reports.reportModal + }, isLoggedIn () { return !!this.$store.state.users.currentUser }, isOpen () { - return this.isLoggedIn && this.$store.state.reports.modalActivated + return this.isLoggedIn && this.reportModal.activated }, userId () { - return this.$store.state.reports.userId + return this.reportModal.userId }, user () { return this.$store.getters.findUser(this.userId) @@ -37,10 +39,10 @@ const UserReportingModal = { return !this.user.is_local && this.user.screen_name.substr(this.user.screen_name.indexOf('@') + 1) }, statuses () { - return this.$store.state.reports.statuses + return this.reportModal.statuses }, preTickedIds () { - return this.$store.state.reports.preTickedIds + return this.reportModal.preTickedIds } }, watch: { diff --git a/src/modules/reports.js b/src/modules/reports.js index e800cfed4f..93866e20c9 100644 --- a/src/modules/reports.js +++ b/src/modules/reports.js @@ -18,7 +18,7 @@ const reports = { state.reportModal.activated = true }, closeUserReportingModal (state) { - state.reportModal.modalActivated = false + state.reportModal.activated = false }, setReportState (reportsState, { id, state }) { reportsState.reports[id].state = state diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 4e5f674b04..9bc908872a 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -498,7 +498,8 @@ const fetchTimeline = ({ userId = false, tag = false, withMuted = false, - replyVisibility = 'all' + replyVisibility = 'all', + includeTypes = [] }) => { const timelineUrls = { public: MASTODON_PUBLIC_TIMELINE, @@ -545,6 +546,11 @@ const fetchTimeline = ({ if (replyVisibility !== 'all') { params.push(['reply_visibility', replyVisibility]) } + if (includeTypes.length > 0) { + includeTypes.forEach(type => { + params.push(['include_types[]', type]) + }) + } params.push(['limit', 20]) diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 91861b21bd..2da6d64618 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -1,6 +1,18 @@ import apiService from '../api/api.service.js' import { promiseInterval } from '../promise_interval/promise_interval.js' +// For using include_types when fetching notifications. +// Note: chat_mention excluded as pleroma-fe polls them separately +const mastoApiNotificationTypes = [ + 'mention', + 'favourite', + 'reblog', + 'follow', + 'move', + 'pleroma:emoji_reaction', + 'pleroma:report' +] + const update = ({ store, notifications, older }) => { store.dispatch('addNewNotifications', { notifications, older }) } @@ -12,6 +24,9 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => { const timelineData = rootState.statuses.notifications const hideMutedPosts = getters.mergedConfig.hideMutedPosts + if (rootState.users.currentUser.role === 'admin') { + args['includeTypes'] = mastoApiNotificationTypes + } args['withMuted'] = !hideMutedPosts args['timeline'] = 'notifications'