Add exp to PostAlerts, align with LabelsOnMe UI
This commit is contained in:
@@ -3,14 +3,14 @@ import {ModerationCause} from '@atproto/api'
|
|||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
|
||||||
import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription'
|
import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription'
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {listUriToHref} from '#/lib/strings/url-helpers'
|
import {listUriToHref} from '#/lib/strings/url-helpers'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useGutters, useTheme} from '#/alf'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Divider} from '#/components/Divider'
|
|
||||||
import {InlineLinkText} from '#/components/Link'
|
import {InlineLinkText} from '#/components/Link'
|
||||||
import {AppModerationCause} from '#/components/Pills'
|
import {AppModerationCause} from '#/components/Pills'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
@@ -38,9 +38,11 @@ function ModerationDetailsDialogInner({
|
|||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogOuterProps['control']
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
const xGutters = useGutters([0, 'base'])
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const desc = useModerationCauseDescription(modcause)
|
const desc = useModerationCauseDescription(modcause)
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const timeDiff = useGetTimeAgo()
|
||||||
|
|
||||||
let name
|
let name
|
||||||
let description
|
let description
|
||||||
@@ -128,37 +130,79 @@ function ModerationDetailsDialogInner({
|
|||||||
description = ''
|
description = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sourceName =
|
||||||
|
desc.source || desc.sourceDisplayName || _(msg`an unknown labeler`)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.ScrollableInner label={_(msg`Moderation details`)}>
|
<Dialog.ScrollableInner
|
||||||
<Text emoji style={[t.atoms.text, a.text_2xl, a.font_bold, a.mb_sm]}>
|
label={_(msg`Moderation details`)}
|
||||||
|
contentContainerStyle={{
|
||||||
|
paddingLeft: 0,
|
||||||
|
paddingRight: 0,
|
||||||
|
paddingBottom: 0,
|
||||||
|
}}>
|
||||||
|
<View style={[xGutters, a.pb_lg]}>
|
||||||
|
<Text emoji style={[t.atoms.text, a.text_2xl, a.font_heavy, a.mb_sm]}>
|
||||||
{name}
|
{name}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[t.atoms.text, a.text_md, a.leading_snug]}>
|
<Text style={[t.atoms.text, a.text_sm, a.leading_snug]}>
|
||||||
{description}
|
{description}
|
||||||
</Text>
|
</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
{modcause?.type === 'label' && (
|
{modcause?.type === 'label' && (
|
||||||
<View style={[a.pt_lg]}>
|
<View
|
||||||
<Divider />
|
style={[
|
||||||
|
xGutters,
|
||||||
|
a.py_md,
|
||||||
|
a.border_t,
|
||||||
|
!isNative && t.atoms.bg_contrast_25,
|
||||||
|
t.atoms.border_contrast_low,
|
||||||
|
{
|
||||||
|
borderBottomLeftRadius: a.rounded_md.borderRadius,
|
||||||
|
borderBottomRightRadius: a.rounded_md.borderRadius,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
{modcause.source.type === 'user' ? (
|
{modcause.source.type === 'user' ? (
|
||||||
<Text style={[t.atoms.text, a.text_md, a.leading_snug, a.mt_lg]}>
|
<Text style={[t.atoms.text, a.text_md, a.leading_snug]}>
|
||||||
<Trans>This label was applied by the author.</Trans>
|
<Trans>This label was applied by the author.</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Text style={[t.atoms.text, a.text_md, a.leading_snug, a.mt_lg]}>
|
<View style={[a.flex_row, a.justify_between, a.gap_xl]}>
|
||||||
<Trans>
|
<Text
|
||||||
This label was applied by{' '}
|
style={[
|
||||||
|
a.flex_1,
|
||||||
|
a.leading_snug,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
]}
|
||||||
|
numberOfLines={1}>
|
||||||
|
<Text style={[a.leading_snug, t.atoms.text_contrast_medium]}>
|
||||||
|
<Trans>Source: </Trans>{' '}
|
||||||
|
</Text>
|
||||||
<InlineLinkText
|
<InlineLinkText
|
||||||
label={desc.source || _(msg`an unknown labeler`)}
|
label={sourceName}
|
||||||
to={makeProfileLink({did: modcause.label.src, handle: ''})}
|
to={makeProfileLink({did: modcause.label.src, handle: ''})}
|
||||||
onPress={() => control.close()}
|
onPress={() => control.close()}>
|
||||||
style={a.text_md}>
|
{sourceName}
|
||||||
{desc.source || _(msg`an unknown labeler`)}
|
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
.
|
</Text>
|
||||||
|
{modcause.label.exp && (
|
||||||
|
<View>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
a.leading_snug,
|
||||||
|
a.text_sm,
|
||||||
|
a.italic,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
]}>
|
||||||
|
<Trans>
|
||||||
|
Expires in {timeDiff(Date.now(), modcause.label.exp)}
|
||||||
</Trans>
|
</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {useLabelDefinitions} from '#/state/preferences'
|
import {useLabelDefinitions} from '#/state/preferences'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {CircleBanSign_Stroke2_Corner0_Rounded as CircleBanSign} from '#/components/icons/CircleBanSign'
|
import {CircleBanSign_Stroke2_Corner0_Rounded as CircleBanSign} from '#/components/icons/CircleBanSign'
|
||||||
@@ -23,6 +24,7 @@ export interface ModerationCauseDescription {
|
|||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
source?: string
|
source?: string
|
||||||
|
sourceDisplayName?: string
|
||||||
sourceType?: ModerationCauseSource['type']
|
sourceType?: ModerationCauseSource['type']
|
||||||
sourceAvi?: string
|
sourceAvi?: string
|
||||||
sourceDid?: string
|
sourceDid?: string
|
||||||
@@ -130,14 +132,16 @@ export function useModerationCauseDescription(
|
|||||||
const def = cause.labelDef || getDefinition(labelDefs, cause.label)
|
const def = cause.labelDef || getDefinition(labelDefs, cause.label)
|
||||||
const strings = getLabelStrings(i18n.locale, globalLabelStrings, def)
|
const strings = getLabelStrings(i18n.locale, globalLabelStrings, def)
|
||||||
const labeler = labelers.find(l => l.creator.did === cause.label.src)
|
const labeler = labelers.find(l => l.creator.did === cause.label.src)
|
||||||
let source =
|
let source = labeler
|
||||||
labeler?.creator.displayName ||
|
? sanitizeHandle(labeler.creator.handle, '@')
|
||||||
(labeler?.creator.handle ? '@' + labeler?.creator.handle : undefined)
|
: undefined
|
||||||
|
let sourceDisplayName = labeler?.creator.displayName
|
||||||
if (!source) {
|
if (!source) {
|
||||||
if (cause.label.src === BSKY_LABELER_DID) {
|
if (cause.label.src === BSKY_LABELER_DID) {
|
||||||
source = 'Bluesky Moderation Service'
|
source = 'moderation.bsky.app'
|
||||||
|
sourceDisplayName = 'Bluesky Moderation Service'
|
||||||
} else {
|
} else {
|
||||||
source = cause.label.src
|
source = _(msg`an unknown labeler`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (def.identifier === 'porn' || def.identifier === 'sexual') {
|
if (def.identifier === 'porn' || def.identifier === 'sexual') {
|
||||||
@@ -154,6 +158,7 @@ export function useModerationCauseDescription(
|
|||||||
name: strings.name,
|
name: strings.name,
|
||||||
description: strings.description,
|
description: strings.description,
|
||||||
source,
|
source,
|
||||||
|
sourceDisplayName,
|
||||||
sourceType: cause.source.type,
|
sourceType: cause.source.type,
|
||||||
sourceAvi: labeler?.creator.avatar,
|
sourceAvi: labeler?.creator.avatar,
|
||||||
sourceDid: cause.label.src,
|
sourceDid: cause.label.src,
|
||||||
|
|||||||
Reference in New Issue
Block a user