From 097823d790704e113f1a2a36591b221461af339d Mon Sep 17 00:00:00 2001 From: sfr Date: Sun, 31 Jul 2022 21:47:25 +0000 Subject: [PATCH] Add toggle to hide posts mentioning blocked users (#78) Reviewed-on: https://akkoma.dev/AkkomaGang/pleroma-fe/pulls/78 Co-authored-by: sfr Co-committed-by: sfr --- .../settings_modal/tabs/filtering_tab.vue | 9 +++++++ src/components/status/status.js | 26 +++++++++++++++++-- src/i18n/en.json | 1 + src/modules/config.js | 1 + src/modules/instance.js | 1 + 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/components/settings_modal/tabs/filtering_tab.vue b/src/components/settings_modal/tabs/filtering_tab.vue index 97046ff0..7160b1fd 100644 --- a/src/components/settings_modal/tabs/filtering_tab.vue +++ b/src/components/settings_modal/tabs/filtering_tab.vue @@ -37,6 +37,15 @@ {{ $t('settings.hide_muted_posts') }} +
  • + + {{ $t('settings.hide_threads_with_blocked_users') }} + +
  • diff --git a/src/components/status/status.js b/src/components/status/status.js index dcf93688..a8bc4153 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -261,6 +261,22 @@ const Status = { hasMentionsLine () { return this.mentionsLine.length > 0 }, + mentionsBlockedUser () { + // XXX: doesn't work on domain blocks, because users from blocked domains + // don't appear in `attentions' and therefore cannot be filtered. + let mentions = false + + // find if user in mentions list is blocked + this.status.attentions.forEach((attn) => { + if (attn.id === this.currentUser.id) return + const relationship = this.$store.getters.relationship(attn.id) + if (relationship.blocking) { + mentions = true + } + }) + + return mentions + }, muted () { if (this.statusoid.user.id === this.currentUser.id) return false const reasonsToMute = this.userIsMuted || @@ -269,7 +285,9 @@ const Status = { // Wordfiltered this.muteWordHits.length > 0 || // bot status - (this.muteBotStatuses && this.botStatus && !this.compact) + (this.muteBotStatuses && this.botStatus && !this.compact) || + // mentions blocked user + this.mentionsBlockedUser return !this.unmuted && !this.shouldNotMute && reasonsToMute }, userIsMuted () { @@ -312,6 +330,9 @@ const Status = { hideFilteredStatuses () { return this.mergedConfig.hideFilteredStatuses }, + hideThreadsWithBlockedUsers () { + return this.mergedConfig.hideThreadsWithBlockedUsers + }, hideWordFilteredPosts () { return this.mergedConfig.hideWordFilteredPosts }, @@ -320,7 +341,8 @@ const Status = { (this.muted && this.hideFilteredStatuses) || (this.userIsMuted && this.hideMutedUsers) || (this.status.thread_muted && this.hideMutedThreads) || - (this.muteWordHits.length > 0 && this.hideWordFilteredPosts) + (this.muteWordHits.length > 0 && this.hideWordFilteredPosts) || + (this.mentionsBlockedUser && this.hideThreadsWithBlockedUsers) ) }, isFocused () { diff --git a/src/i18n/en.json b/src/i18n/en.json index 0cfec3f3..9dbe4ea8 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -424,6 +424,7 @@ "hide_shoutbox": "Hide instance shoutbox", "right_sidebar": "Reverse order of columns", "always_show_post_button": "Always show floating New Post button", + "hide_threads_with_blocked_users": "Hide threads tagging blocked users", "hide_wallpaper": "Hide instance wallpaper", "preload_images": "Preload images", "use_one_click_nsfw": "Open NSFW attachments with just one click", diff --git a/src/modules/config.js b/src/modules/config.js index 9ffe39bd..e0cba098 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -31,6 +31,7 @@ export const defaultState = { // bad name: actually hides posts of muted USERS hideMutedPosts: undefined, // instance default hideMutedThreads: undefined, // instance default + hideThreadsWithBlockedUsers: undefined, // instance default hideWordFilteredPosts: undefined, // instance default muteBotStatuses: undefined, // instance default collapseMessageWithSubject: true, // instance default diff --git a/src/modules/instance.js b/src/modules/instance.js index 8fe7f7a0..1ab6365f 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -30,6 +30,7 @@ const defaultState = { // bad name: actually hides posts of muted USERS hideMutedPosts: false, hideMutedThreads: true, + hideThreadsWithBlockedUsers: false, hideWordFilteredPosts: false, hidePostStats: false, hideBotIndication: false,