Fix read more extra space

This commit is contained in:
Eric Bailey
2025-05-29 21:33:51 -05:00
parent ab18cfaa34
commit e6e1ca3415
4 changed files with 19 additions and 18 deletions
@@ -221,7 +221,6 @@ const ThreadReplyInner = memo(function ThreadReplyInner({
!item.ui.showChildReplyLine && a.pb_sm,
],
item.ui.isLastChild &&
!item.ui.precedesParentReadMore &&
!item.ui.precedesChildReadMore && [a.pb_sm],
]}>
{item.ui.indent > 1 && (
@@ -341,6 +341,7 @@ export function traverse(
* it itself needs a "read more"
*/
if (metadata.repliesUnhydrated > 0 && metadata.isLastChild) {
metadata.precedesChildReadMore = true
items.splice(i + 1, 0, views.readMore(metadata))
i++ // skip next iteration
}
+11 -16
View File
@@ -51,18 +51,7 @@ export type Slice =
indent: number
isLastChild: boolean
skippedIndentIndices: Set<number>
/**
* Populated during the final traversal of the thread. Denotes whether
* there is a "Read more" link for the parent immediately following
* this item.
*/
precedesParentReadMore?: boolean
/**
* Populated during the final traversal of the thread. Denotes whether
* there is a "Read more" link for this item immediately following
* this item.
*/
precedesChildReadMore?: boolean
precedesChildReadMore: boolean
}
}
| {
@@ -127,15 +116,21 @@ export type TraversalMetadata = {
* The depth of the slice immediately following this one, if it exists.
*/
nextItemDepth?: number
/**
* The depth of the slice immediately preceding this one, if it exists.
*/
prevItemDepth?: number
/**
* This is a live reference to the parent metadata object. Mutations to this
* are available for later use in children.
*/
parentMetadata?: TraversalMetadata
/**
* Populated during the final traversal of the thread. Denotes whether
* there is a "Read more" link for this item immediately following
* this item.
*/
precedesChildReadMore: boolean
/**
* The depth of the slice immediately preceding this one, if it exists.
*/
prevItemDepth?: number
/**
* Any data needed to be passed along to the "read more" items. Keep this
* trim for better memory usage.
+7 -1
View File
@@ -76,8 +76,12 @@ export function getTraversalMetadata({
*/
isPartOfLastBranchFromDepth: item.depth === 1 ? 1 : undefined,
nextItemDepth: nextItem?.depth,
prevItemDepth: prevItem?.depth,
parentMetadata,
prevItemDepth: prevItem?.depth,
/*
* Unknown until after traversal
*/
precedesChildReadMore: false,
postData: {
uri: item.uri,
authorHandle: item.value.post.author.handle,
@@ -119,6 +123,7 @@ export function getThreadPostUI({
skippedIndentIndices,
repliesSeenCount,
repliesUnhydrated,
precedesChildReadMore,
}: TraversalMetadata): Extract<Slice, {type: 'threadPost'}>['ui'] {
// TODO might be able to simplify this
const isReplyAndHasReplies =
@@ -138,5 +143,6 @@ export function getThreadPostUI({
*/
isLastChild, //nextItemDepth === undefined || nextItemDepth < depth,
skippedIndentIndices,
precedesChildReadMore: precedesChildReadMore ?? false,
}
}