diff --git a/src/components/Pills.tsx b/src/components/Pills.tsx index d48089f883..742a11667c 100644 --- a/src/components/Pills.tsx +++ b/src/components/Pills.tsx @@ -17,7 +17,7 @@ export type AppModerationCause = | ModerationCause | { type: 'reply-hidden' - source: {type: 'user'} + source: {type: 'user'; did: string} priority: 6 downgraded?: boolean } diff --git a/src/lib/moderation/useModerationCauseDescription.ts b/src/lib/moderation/useModerationCauseDescription.ts index 1ccb4c65b4..4728e1e69c 100644 --- a/src/lib/moderation/useModerationCauseDescription.ts +++ b/src/lib/moderation/useModerationCauseDescription.ts @@ -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, + ]) } diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 5910b121d0..9cae8a3c77 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -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 || '',