Add OP thread numbering to feed posts (#11472)

This commit is contained in:
DS Boyce
2026-08-25 11:48:27 -07:00
committed by GitHub
parent 7750882fd0
commit f968c9e721
7 changed files with 122 additions and 13 deletions
@@ -11,12 +11,17 @@ import {type app} from '#/lexicons'
*/
export const POST_NUMBER_INLINE_OFFSET = 6
export type ThreadItemPostNumbering = Pick<
app.bsky.unspecced.defs.ThreadItemPost,
'opThreadPostIndex' | 'opThreadPostCount'
>
export function useHasThreadItemPostNumber(
value: app.bsky.unspecced.defs.ThreadItemPost,
value: ThreadItemPostNumbering | undefined,
) {
const ax = useAnalytics()
const index = value.opThreadPostIndex
const count = value.opThreadPostCount
const index = value?.opThreadPostIndex
const count = value?.opThreadPostCount
return (
ax.features.enabled(ax.features.CanonicalPostNumberingEnable) &&
@@ -32,14 +37,14 @@ export function ThreadItemPostNumber({
value,
inline = true,
}: {
value: app.bsky.unspecced.defs.ThreadItemPost
value: ThreadItemPostNumbering | undefined
inline?: boolean
}) {
const t = useTheme()
const {t: l} = useLingui()
const shouldRender = useHasThreadItemPostNumber(value)
const index = value.opThreadPostIndex
const count = value.opThreadPostCount
const index = value?.opThreadPostIndex
const count = value?.opThreadPostCount
if (!shouldRender) {
return null
@@ -59,7 +64,8 @@ export function ThreadItemPostNumber({
},
inline
? platform({
native: {transform: [{translateY: POST_NUMBER_INLINE_OFFSET}]},
android: {transform: [{translateY: POST_NUMBER_INLINE_OFFSET}]},
ios: {transform: [{translateY: a.py_2xs.paddingBottom}]},
web: {
top: -2,
marginBottom: -2,