Fix read more extra space
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user