WIP OP continuous thread
This commit is contained in:
@@ -151,6 +151,17 @@ export function sortAndAnnotateThreadItems(
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!post.isBlurred || skipModerationHandling) {
|
if (!post.isBlurred || skipModerationHandling) {
|
||||||
|
const skip =
|
||||||
|
parentMetadata?.isPartOfOPThreadFromRoot &&
|
||||||
|
!metadata?.isPartOfOPThreadFromRoot
|
||||||
|
|
||||||
|
if (skip) {
|
||||||
|
const branch = getBranch(thread, i, item.depth)
|
||||||
|
// could insert tombstone
|
||||||
|
i = branch.end
|
||||||
|
continue traversal
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not moderated, need to insert it
|
* Not moderated, need to insert it
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -155,6 +155,16 @@ export type TraversalMetadata = {
|
|||||||
* tree. Value corresponds to the depth at which this branch started.
|
* tree. Value corresponds to the depth at which this branch started.
|
||||||
*/
|
*/
|
||||||
isPartOfLastBranchFromDepth?: number
|
isPartOfLastBranchFromDepth?: number
|
||||||
|
/**
|
||||||
|
* Indicates if the post is part of the thread started by the original
|
||||||
|
* poster, starting from the root post. OP threads within other branches
|
||||||
|
* of the tree are not considered part of the OP thread.
|
||||||
|
*/
|
||||||
|
isPartOfOPThreadFromRoot: boolean
|
||||||
|
/**
|
||||||
|
* Indicates if this item is the root post of the thread.
|
||||||
|
*/
|
||||||
|
isRoot: boolean
|
||||||
/**
|
/**
|
||||||
* The depth of the slice immediately following this one, if it exists.
|
* The depth of the slice immediately following this one, if it exists.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -63,6 +63,13 @@ export function getTraversalMetadata({
|
|||||||
if (!AppBskyUnspeccedDefs.isThreadItemPost(item.value)) {
|
if (!AppBskyUnspeccedDefs.isThreadItemPost(item.value)) {
|
||||||
throw new Error(`Expected thread item to be a post`)
|
throw new Error(`Expected thread item to be a post`)
|
||||||
}
|
}
|
||||||
|
const rootUri = getRootPostAtUri(item.value.post)
|
||||||
|
const rootAuthorDid = rootUri?.host
|
||||||
|
const isRoot = item.uri === item.value.post.uri
|
||||||
|
const isPartOfOPThreadFromRoot = Boolean(
|
||||||
|
item.value.post.author.did === rootAuthorDid &&
|
||||||
|
(parentMetadata?.isRoot || parentMetadata?.isPartOfOPThreadFromRoot),
|
||||||
|
)
|
||||||
const repliesCount = item.value.post.replyCount || 0
|
const repliesCount = item.value.post.replyCount || 0
|
||||||
const repliesUnhydrated = item.value.moreReplies || 0
|
const repliesUnhydrated = item.value.moreReplies || 0
|
||||||
const metadata = {
|
const metadata = {
|
||||||
@@ -81,6 +88,8 @@ export function getTraversalMetadata({
|
|||||||
* replies, we'll override this after traversal.
|
* replies, we'll override this after traversal.
|
||||||
*/
|
*/
|
||||||
isPartOfLastBranchFromDepth: item.depth === 1 ? 1 : undefined,
|
isPartOfLastBranchFromDepth: item.depth === 1 ? 1 : undefined,
|
||||||
|
isPartOfOPThreadFromRoot,
|
||||||
|
isRoot,
|
||||||
nextItemDepth: nextItem?.depth,
|
nextItemDepth: nextItem?.depth,
|
||||||
parentMetadata,
|
parentMetadata,
|
||||||
prevItemDepth: prevItem?.depth,
|
prevItemDepth: prevItem?.depth,
|
||||||
@@ -130,6 +139,7 @@ export function getThreadPostUI({
|
|||||||
repliesCount,
|
repliesCount,
|
||||||
prevItemDepth,
|
prevItemDepth,
|
||||||
isLastChild,
|
isLastChild,
|
||||||
|
isPartOfOPThreadFromRoot,
|
||||||
skippedIndentIndices,
|
skippedIndentIndices,
|
||||||
repliesSeenCounter,
|
repliesSeenCounter,
|
||||||
repliesUnhydrated,
|
repliesUnhydrated,
|
||||||
@@ -147,7 +157,7 @@ export function getThreadPostUI({
|
|||||||
followsReadMoreUp ||
|
followsReadMoreUp ||
|
||||||
(!!prevItemDepth && prevItemDepth !== 0 && prevItemDepth < depth),
|
(!!prevItemDepth && prevItemDepth !== 0 && prevItemDepth < depth),
|
||||||
showChildReplyLine: depth < 0 || isReplyAndHasReplies,
|
showChildReplyLine: depth < 0 || isReplyAndHasReplies,
|
||||||
indent: depth,
|
indent: isPartOfOPThreadFromRoot ? (depth < 1 ? 0 : 1) : depth,
|
||||||
/*
|
/*
|
||||||
* If there are no slices below this one, or the next slice has a depth <=
|
* If there are no slices below this one, or the next slice has a depth <=
|
||||||
* than the depth of this post, it's the last child of the reply tree. It
|
* than the depth of this post, it's the last child of the reply tree. It
|
||||||
|
|||||||
Reference in New Issue
Block a user