Add toggle to hide posts mentioning blocked users #78

Merged
floatingghost merged 1 commit from :hide-blocked-threads into develop 2022-07-31 21:47:25 +00:00
5 changed files with 36 additions and 2 deletions

View file

@ -37,6 +37,15 @@
{{ $t('settings.hide_muted_posts') }}
</BooleanSetting>
</li>
<li>
<BooleanSetting
v-if="user"
:disabled="hideFilteredStatuses"
path="hideThreadsWithBlockedUsers"
>
{{ $t('settings.hide_threads_with_blocked_users') }}
</BooleanSetting>
</li>
</ul>
</li>
<li>

View file

@ -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) => {
Review

whilst this works, you could also do

return this.status.find((attn) => {
  if (attn.id === this.currentUser.id) return false;
  const relationship = this.$store.getters.relationship(attn.id)
  if (relationship.blocking) {
    return true;
  }
  return false;
}) !== undefined;

which avoids the mutating boolean thing you've got going on there

whilst this works, you could also do ```js return this.status.find((attn) => { if (attn.id === this.currentUser.id) return false; const relationship = this.$store.getters.relationship(attn.id) if (relationship.blocking) { return true; } return false; }) !== undefined; ``` which avoids the mutating boolean thing you've got going on there
Review

this is clever but i think it's less immediately readable this way

this is clever but i think it's less immediately readable this way
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 () {

View file

@ -458,6 +458,7 @@
"hide_muted_threads": "Hide muted threads",
"hide_post_stats": "Hide post statistics (e.g. the number of favorites)",
"hide_shoutbox": "Hide instance shoutbox",
"hide_threads_with_blocked_users": "Hide threads tagging blocked users",
"hide_user_stats": "Hide user statistics (e.g. the number of followers)",
"hide_wallpaper": "Hide instance wallpaper",
"hide_wordfiltered_statuses": "Hide word-filtered statuses",

View file

@ -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: undefined, // instance default

View file

@ -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,