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