[APP-2642] Social proof text is truncated on mobile (#11155)
This commit is contained in:
@@ -5,10 +5,11 @@ import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
|||||||
|
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
|
import {enforceLen} from '#/lib/strings/helpers'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useLikedBySampleQuery} from '#/state/queries/post-liked-by'
|
import {useLikedBySampleQuery} from '#/state/queries/post-liked-by'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {AvatarStack} from '#/components/AvatarStack'
|
import {AvatarStack} from '#/components/AvatarStack'
|
||||||
import {InlineLinkText, Link} from '#/components/Link'
|
import {InlineLinkText, Link} from '#/components/Link'
|
||||||
import {useFormatPostStatCount} from '#/components/PostControls/util'
|
import {useFormatPostStatCount} from '#/components/PostControls/util'
|
||||||
@@ -17,6 +18,7 @@ import {Text} from '#/components/Typography'
|
|||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
|
|
||||||
const AVI_SIZE = 20
|
const AVI_SIZE = 20
|
||||||
|
const MAX_NAME_LENGTH = 16
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The likes stat for the expanded anchor post. When the viewer follows some
|
* The likes stat for the expanded anchor post. When the viewer follows some
|
||||||
@@ -32,6 +34,7 @@ const AVI_SIZE = 20
|
|||||||
*/
|
*/
|
||||||
export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
|
export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
const {gtMobile} = useBreakpoints()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const {hasSession, currentAccount} = useSession()
|
const {hasSession, currentAccount} = useSession()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
@@ -98,16 +101,21 @@ export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
|
|||||||
const aviStackProfiles = knownLikersAndModeration
|
const aviStackProfiles = knownLikersAndModeration
|
||||||
.slice(0, 3)
|
.slice(0, 3)
|
||||||
.map(({actor}) => actor)
|
.map(({actor}) => actor)
|
||||||
|
const maxNames = gtMobile ? 2 : 1
|
||||||
const names = knownLikersAndModeration
|
const names = knownLikersAndModeration
|
||||||
.slice(0, 2)
|
.slice(0, maxNames)
|
||||||
.map(({actor, moderation}) => {
|
.map(({actor, moderation}) => {
|
||||||
return {
|
return {
|
||||||
did: actor.did,
|
did: actor.did,
|
||||||
href: makeProfileLink(actor),
|
href: makeProfileLink(actor),
|
||||||
displayName: sanitizeDisplayName(
|
displayName: enforceLen(
|
||||||
|
sanitizeDisplayName(
|
||||||
actor.displayName || actor.handle,
|
actor.displayName || actor.handle,
|
||||||
moderation.ui('displayName'),
|
moderation.ui('displayName'),
|
||||||
),
|
),
|
||||||
|
MAX_NAME_LENGTH,
|
||||||
|
true,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const others = likeCount - names.length
|
const others = likeCount - names.length
|
||||||
|
|||||||
Reference in New Issue
Block a user