Use indent ya idiot
This commit is contained in:
@@ -179,7 +179,11 @@ let PostThreadItemLoaded = ({
|
|||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.flex_row,
|
a.flex_row,
|
||||||
item.ui.indent === 1 && [a.border_t, t.atoms.border_contrast_low],
|
item.ui.indent === 1 &&
|
||||||
|
!item.ui.showParentReplyLine && [
|
||||||
|
a.border_t,
|
||||||
|
t.atoms.border_contrast_low,
|
||||||
|
],
|
||||||
]}>
|
]}>
|
||||||
{Array.from(Array(item.ui.indent - 1)).map((_, n: number) => (
|
{Array.from(Array(item.ui.indent - 1)).map((_, n: number) => (
|
||||||
<View
|
<View
|
||||||
@@ -196,7 +200,15 @@ let PostThreadItemLoaded = ({
|
|||||||
))}
|
))}
|
||||||
<View style={a.flex_1}>
|
<View style={a.flex_1}>
|
||||||
<SubtleHover>
|
<SubtleHover>
|
||||||
<View style={[a.px_lg, a.pt_sm, item.ui.indent === 1 && [a.pt_lg]]}>
|
<View
|
||||||
|
style={[
|
||||||
|
a.px_lg,
|
||||||
|
a.pt_sm,
|
||||||
|
item.ui.indent === 1 && [
|
||||||
|
!item.ui.showParentReplyLine && a.pt_lg,
|
||||||
|
!item.ui.showChildReplyLine && a.pb_sm,
|
||||||
|
],
|
||||||
|
]}>
|
||||||
<PostHider
|
<PostHider
|
||||||
testID={`postThreadItem-by-${post.author.handle}`}
|
testID={`postThreadItem-by-${post.author.handle}`}
|
||||||
href={postHref}
|
href={postHref}
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ export function flatten(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(flattened)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert hidden items and buttons to show them
|
* Insert hidden items and buttons to show them
|
||||||
@@ -199,18 +200,16 @@ export function sort(
|
|||||||
) {
|
) {
|
||||||
items.push(views.threadPostBlocked(item))
|
items.push(views.threadPostBlocked(item))
|
||||||
} else if (AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) {
|
} else if (AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) {
|
||||||
postDataMap.set(item.uri, getPostTraversalMetadata(item))
|
const post = views.threadPost({
|
||||||
|
|
||||||
items.push(
|
|
||||||
views.threadPost({
|
|
||||||
uri: item.uri,
|
uri: item.uri,
|
||||||
depth: item.depth,
|
depth: item.depth,
|
||||||
value: item.value,
|
value: item.value,
|
||||||
oneUp: thread[i - 1],
|
oneUp: thread[i - 1],
|
||||||
oneDown: thread[i + 1],
|
oneDown: thread[i + 1],
|
||||||
moderationOpts,
|
moderationOpts,
|
||||||
}),
|
})
|
||||||
)
|
postDataMap.set(item.uri, getPostTraversalMetadata(post))
|
||||||
|
items.push(post)
|
||||||
|
|
||||||
parentTraversal: for (let pi = i - 1; pi >= 0; pi--) {
|
parentTraversal: for (let pi = i - 1; pi >= 0; pi--) {
|
||||||
const parentOneDown = thread[pi + 1]
|
const parentOneDown = thread[pi + 1]
|
||||||
@@ -269,8 +268,6 @@ export function sort(
|
|||||||
i = branch.end
|
i = branch.end
|
||||||
continue traversal
|
continue traversal
|
||||||
} else if (AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) {
|
} else if (AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) {
|
||||||
postDataMap.set(item.uri, getPostTraversalMetadata(item))
|
|
||||||
|
|
||||||
const oneUp = thread.at(i - 1)
|
const oneUp = thread.at(i - 1)
|
||||||
const oneDown = thread.at(i + 1)
|
const oneDown = thread.at(i + 1)
|
||||||
const post = views.threadPost({
|
const post = views.threadPost({
|
||||||
@@ -284,6 +281,7 @@ export function sort(
|
|||||||
oneDown,
|
oneDown,
|
||||||
moderationOpts,
|
moderationOpts,
|
||||||
})
|
})
|
||||||
|
postDataMap.set(item.uri, getPostTraversalMetadata(post))
|
||||||
const postMod = getModerationState(post.moderation)
|
const postMod = getModerationState(post.moderation)
|
||||||
const postIsHiddenByThreadgate = threadgateHiddenReplies.has(item.uri)
|
const postIsHiddenByThreadgate = threadgateHiddenReplies.has(item.uri)
|
||||||
const postIsModerated =
|
const postIsModerated =
|
||||||
@@ -318,8 +316,6 @@ export function sort(
|
|||||||
if (
|
if (
|
||||||
AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(child.value)
|
AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(child.value)
|
||||||
) {
|
) {
|
||||||
postDataMap.set(child.uri, getPostTraversalMetadata(child))
|
|
||||||
|
|
||||||
const childPost = views.threadPost({
|
const childPost = views.threadPost({
|
||||||
uri: child.uri,
|
uri: child.uri,
|
||||||
depth: child.depth,
|
depth: child.depth,
|
||||||
@@ -331,6 +327,7 @@ export function sort(
|
|||||||
oneDown: thread[ci + 1],
|
oneDown: thread[ci + 1],
|
||||||
moderationOpts,
|
moderationOpts,
|
||||||
})
|
})
|
||||||
|
postDataMap.set(child.uri, getPostTraversalMetadata(childPost))
|
||||||
const childPostMod = getModerationState(childPost.moderation)
|
const childPostMod = getModerationState(childPost.moderation)
|
||||||
const childPostIsHiddenByThreadgate =
|
const childPostIsHiddenByThreadgate =
|
||||||
threadgateHiddenReplies.has(child.uri)
|
threadgateHiddenReplies.has(child.uri)
|
||||||
|
|||||||
@@ -93,6 +93,6 @@ export type Slice =
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type TraversalMetadata = {
|
export type TraversalMetadata = {
|
||||||
depth: number
|
indent: number
|
||||||
hasBranchingReplies: boolean
|
hasBranchingReplies: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import {
|
|||||||
AtUri,
|
AtUri,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
|
||||||
import {type TraversalMetadata} from '#/state/queries/usePostThread/types'
|
import {
|
||||||
|
type Slice,
|
||||||
|
type TraversalMetadata,
|
||||||
|
} from '#/state/queries/usePostThread/types'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function getThreadgateRecord(
|
export function getThreadgateRecord(
|
||||||
@@ -38,13 +41,13 @@ export function getPostRecord(post: AppBskyFeedDefs.PostView) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getPostTraversalMetadata(
|
export function getPostTraversalMetadata(
|
||||||
item: AppBskyUnspeccedGetPostThreadV2.ThreadItem,
|
item: Extract<Slice, {type: 'threadPost'}>,
|
||||||
): TraversalMetadata | undefined {
|
): TraversalMetadata | undefined {
|
||||||
if (!AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) return
|
if (!AppBskyUnspeccedGetPostThreadV2.isThreadItemPost(item.value)) return
|
||||||
const replyCount = item.value.post.replyCount || 0
|
const replyCount = item.value.post.replyCount || 0
|
||||||
const unhydratedReplies = item.value.moreReplies || 0
|
const unhydratedReplies = item.value.moreReplies || 0
|
||||||
return {
|
return {
|
||||||
depth: item.depth,
|
indent: item.ui.indent,
|
||||||
/**
|
/**
|
||||||
* If the post has more than a single reply, and the total reply count
|
* If the post has more than a single reply, and the total reply count
|
||||||
* minus the number of replies not present in the response is greater than
|
* minus the number of replies not present in the response is greater than
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export function threadPost({
|
|||||||
showChildReplyLine: (value.post.replyCount || 0) > 0,
|
showChildReplyLine: (value.post.replyCount || 0) > 0,
|
||||||
indent: traversalMetadata?.hasBranchingReplies
|
indent: traversalMetadata?.hasBranchingReplies
|
||||||
? depth
|
? depth
|
||||||
: traversalMetadata?.depth || depth,
|
: traversalMetadata?.indent || depth,
|
||||||
parentHasBranchingReplies: !!traversalMetadata?.hasBranchingReplies,
|
parentHasBranchingReplies: !!traversalMetadata?.hasBranchingReplies,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ export function readMore({
|
|||||||
key: `readMore:${parent.uri}`,
|
key: `readMore:${parent.uri}`,
|
||||||
indent: parent.ui.parentHasBranchingReplies
|
indent: parent.ui.parentHasBranchingReplies
|
||||||
? parent.depth
|
? parent.depth
|
||||||
: Math.max(0, parent.depth - 1),
|
: parent.ui.indent,
|
||||||
replyCount: parent.value.moreReplies,
|
replyCount: parent.value.moreReplies,
|
||||||
nextAnchor: parent,
|
nextAnchor: parent,
|
||||||
nextAnchorUri: new AtUri(parent.uri),
|
nextAnchorUri: new AtUri(parent.uri),
|
||||||
|
|||||||
Reference in New Issue
Block a user