sanitize handles properly in draftitem
This commit is contained in:
@@ -476,7 +476,7 @@ Example from Dialog:
|
|||||||
import * as storage from '#/state/drafts/storage'
|
import * as storage from '#/state/drafts/storage'
|
||||||
|
|
||||||
// WRONG - don't use require() or conditional imports for platform files
|
// WRONG - don't use require() or conditional imports for platform files
|
||||||
const storage = isNative
|
const storage = IS_NATIVE
|
||||||
? require('#/state/drafts/storage')
|
? require('#/state/drafts/storage')
|
||||||
: require('#/state/drafts/storage.web')
|
: require('#/state/drafts/storage.web')
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import * as VideoThumbnails from 'expo-video-thumbnails'
|
|||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
||||||
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {useCurrentAccountProfile} from '#/state/queries/useCurrentAccountProfile'
|
import {useCurrentAccountProfile} from '#/state/queries/useCurrentAccountProfile'
|
||||||
import {useSession} from '#/state/session'
|
|
||||||
import {TimeElapsed} from '#/view/com/util/TimeElapsed'
|
import {TimeElapsed} from '#/view/com/util/TimeElapsed'
|
||||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
@@ -108,17 +109,11 @@ function DraftPostRow({
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const profile = useCurrentAccountProfile()
|
const profile = useCurrentAccountProfile()
|
||||||
const {currentAccount} = useSession()
|
|
||||||
|
|
||||||
const displayName =
|
|
||||||
profile?.displayName || profile?.handle || currentAccount?.handle || ''
|
|
||||||
const handle = profile?.handle || currentAccount?.handle || ''
|
|
||||||
const avatarUrl = profile?.avatar
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[a.flex_row, a.gap_sm]}>
|
<View style={[a.flex_row, a.gap_sm]}>
|
||||||
<View style={[a.align_center]}>
|
<View style={[a.align_center]}>
|
||||||
<UserAvatar type="user" size={42} avatar={avatarUrl} />
|
<UserAvatar type="user" size={42} avatar={profile?.avatar} />
|
||||||
{!isLast && (
|
{!isLast && (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
@@ -137,25 +132,45 @@ function DraftPostRow({
|
|||||||
<View style={[a.flex_1, a.gap_2xs]}>
|
<View style={[a.flex_1, a.gap_2xs]}>
|
||||||
<View style={[a.flex_row, a.align_center, a.gap_xs]}>
|
<View style={[a.flex_row, a.align_center, a.gap_xs]}>
|
||||||
<View style={[a.flex_row, a.align_center, a.flex_1, a.gap_xs]}>
|
<View style={[a.flex_row, a.align_center, a.flex_1, a.gap_xs]}>
|
||||||
{displayName && (
|
{profile && (
|
||||||
|
<>
|
||||||
<Text
|
<Text
|
||||||
style={[a.text_md, a.font_semi_bold, t.atoms.text]}
|
style={[
|
||||||
|
a.text_md,
|
||||||
|
a.font_semi_bold,
|
||||||
|
t.atoms.text,
|
||||||
|
a.leading_snug,
|
||||||
|
]}
|
||||||
numberOfLines={1}>
|
numberOfLines={1}>
|
||||||
{displayName}
|
{createSanitizedDisplayName(profile)}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
|
||||||
<Text
|
<Text
|
||||||
style={[a.text_md, t.atoms.text_contrast_medium]}
|
style={[
|
||||||
|
a.text_md,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
a.leading_snug,
|
||||||
|
]}
|
||||||
numberOfLines={1}>
|
numberOfLines={1}>
|
||||||
@{handle}
|
{sanitizeHandle(profile.handle)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[a.text_md, t.atoms.text_contrast_medium]}>
|
<Text
|
||||||
|
style={[
|
||||||
|
a.text_md,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
a.leading_snug,
|
||||||
|
]}>
|
||||||
·
|
·
|
||||||
</Text>
|
</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<TimeElapsed timestamp={timestamp}>
|
<TimeElapsed timestamp={timestamp}>
|
||||||
{({timeElapsed}) => (
|
{({timeElapsed}) => (
|
||||||
<Text
|
<Text
|
||||||
style={[a.text_md, t.atoms.text_contrast_medium]}
|
style={[
|
||||||
|
a.text_md,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
a.leading_snug,
|
||||||
|
]}
|
||||||
numberOfLines={1}>
|
numberOfLines={1}>
|
||||||
{timeElapsed}
|
{timeElapsed}
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user