hide title of moderation list
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
|
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
|
||||||
import {AppBskyGraphDefs, AtUri, RichText} from '@atproto/api'
|
import {AppBskyGraphDefs, AtUri, RichText} from '@atproto/api'
|
||||||
import {Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
@@ -30,11 +31,14 @@ export const ListCard = ({
|
|||||||
renderButton?: () => JSX.Element
|
renderButton?: () => JSX.Element
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
}) => {
|
}) => {
|
||||||
|
const {_} = useLingui()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
const isOwner = currentAccount?.did === list.creator.did
|
const isOwner = currentAccount?.did === list.creator.did
|
||||||
const isListHidden = list.labels?.findIndex(l => l.val === '!hide') !== -1
|
const isListHidden = list.labels?.findIndex(l => l.val === '!hide') !== -1
|
||||||
|
const hideTitle = !isOwner && isListHidden
|
||||||
|
|
||||||
const isModList = list.purpose === 'app.bsky.graph.defs#modlist'
|
const isModList = list.purpose === 'app.bsky.graph.defs#modlist'
|
||||||
const creatorHandle = sanitizeHandle(list.creator.handle, '@')
|
const creatorHandle = sanitizeHandle(list.creator.handle, '@')
|
||||||
|
|
||||||
@@ -68,7 +72,7 @@ export const ListCard = ({
|
|||||||
style,
|
style,
|
||||||
]}
|
]}
|
||||||
href={makeProfileLink(list.creator, 'lists', rkey)}
|
href={makeProfileLink(list.creator, 'lists', rkey)}
|
||||||
title={list.name}
|
title={hideTitle ? _(msg`Hidden list`) : list.name}
|
||||||
asAnchor
|
asAnchor
|
||||||
anchorNoUnderline>
|
anchorNoUnderline>
|
||||||
<View style={styles.layout}>
|
<View style={styles.layout}>
|
||||||
@@ -78,10 +82,10 @@ export const ListCard = ({
|
|||||||
<View style={styles.layoutContent}>
|
<View style={styles.layoutContent}>
|
||||||
<Text
|
<Text
|
||||||
type="lg"
|
type="lg"
|
||||||
style={[s.bold, pal.text]}
|
style={[s.bold, pal.text, hideTitle && {fontStyle: 'italic'}]}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
lineHeight={1.2}>
|
lineHeight={1.2}>
|
||||||
{sanitizeDisplayName(list.name)}
|
{hideTitle ? _(msg`Hidden list`) : sanitizeDisplayName(list.name)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text type="md" style={[pal.textLight]} numberOfLines={1}>
|
<Text type="md" style={[pal.textLight]} numberOfLines={1}>
|
||||||
{isOwner ? (
|
{isOwner ? (
|
||||||
@@ -98,19 +102,14 @@ export const ListCard = ({
|
|||||||
</Text>
|
</Text>
|
||||||
<View style={s.flexRow}>
|
<View style={s.flexRow}>
|
||||||
{list.viewer?.muted ? (
|
{list.viewer?.muted ? (
|
||||||
<View style={[s.mt5, pal.btn, styles.pill]}>
|
<PillText>
|
||||||
<Text type="xs" style={pal.text}>
|
<Trans>Muted</Trans>
|
||||||
<Trans>Muted</Trans>
|
</PillText>
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{list.viewer?.blocked ? (
|
{list.viewer?.blocked ? (
|
||||||
<View style={[s.mt5, pal.btn, styles.pill]}>
|
<PillText>
|
||||||
<Text type="xs" style={pal.text}>
|
<Trans>Blocked</Trans>
|
||||||
<Trans>Blocked</Trans>
|
</PillText>
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -131,6 +130,15 @@ export const ListCard = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PillText({children}: {children: React.ReactNode}) {
|
||||||
|
const pal = usePalette('default')
|
||||||
|
return (
|
||||||
|
<Text type="xs" style={[s.mt5, pal.btn, styles.pill, pal.text]}>
|
||||||
|
{children}
|
||||||
|
</Text>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
outer: {
|
outer: {
|
||||||
borderTopWidth: StyleSheet.hairlineWidth,
|
borderTopWidth: StyleSheet.hairlineWidth,
|
||||||
|
|||||||
Reference in New Issue
Block a user