Show if you hid the reply or not

This commit is contained in:
Eric Bailey
2024-08-09 18:02:59 -05:00
parent df6b592f28
commit 47dfa54ede
3 changed files with 30 additions and 13 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ export type AppModerationCause =
| ModerationCause
| {
type: 'reply-hidden'
source: {type: 'user'}
source: {type: 'user'; did: string}
priority: 6
downgraded?: boolean
}
@@ -8,6 +8,7 @@ import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useLabelDefinitions} from '#/state/preferences'
import {useSession} from '#/state/session'
import {CircleBanSign_Stroke2_Corner0_Rounded as CircleBanSign} from '#/components/icons/CircleBanSign'
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
import {Props as SVGIconProps} from '#/components/icons/common'
@@ -30,6 +31,7 @@ export interface ModerationCauseDescription {
export function useModerationCauseDescription(
cause: ModerationCause | AppModerationCause | undefined,
): ModerationCauseDescription {
const {currentAccount} = useSession()
const {_, i18n} = useLingui()
const {labelDefs, labelers} = useLabelDefinitions()
const globalLabelStrings = useGlobalLabelStrings()
@@ -113,10 +115,15 @@ export function useModerationCauseDescription(
}
}
if (cause.type === 'reply-hidden') {
const isYou = currentAccount?.did === cause.source.did
return {
icon: EyeSlash,
name: _(msg`Post Hidden by Thread Author`),
description: _(msg`The author of this thread has hidden this post.`),
name: isYou
? _(msg`Post hidden by you`)
: _(msg`Post hidden by thread author`),
description: isYou
? _(msg`You hid this post.`)
: _(msg`The author of this thread has hidden this post.`),
}
}
if (cause.type === 'label') {
@@ -158,5 +165,13 @@ export function useModerationCauseDescription(
name: '',
description: ``,
}
}, [labelDefs, labelers, globalLabelStrings, cause, _, i18n.locale])
}, [
labelDefs,
labelers,
globalLabelStrings,
cause,
_,
i18n.locale,
currentAccount?.did,
])
}
+11 -9
View File
@@ -215,15 +215,17 @@ let PostThreadItemLoaded = ({
const isPostHiddenByThreadgate = threadgateRecord?.hiddenReplies?.includes(
post.uri,
)
const additionalPostAlerts: AppModerationCause[] = isPostHiddenByThreadgate
? [
{
type: 'reply-hidden',
source: {type: 'user'},
priority: 6,
},
]
: []
// TODO memoize
const additionalPostAlerts: AppModerationCause[] =
threadgateRecord && isPostHiddenByThreadgate
? [
{
type: 'reply-hidden',
source: {type: 'user', did: new AtUri(threadgateRecord.post).host},
priority: 6,
},
]
: []
const translatorUrl = getTranslatorLink(
record?.text || '',