Fix lines on read more items
This commit is contained in:
@@ -27,7 +27,12 @@ import {TextLink} from '#/view/com/util/Link'
|
|||||||
import {PostCtrls} from '#/view/com/util/post-ctrls/PostCtrls'
|
import {PostCtrls} from '#/view/com/util/post-ctrls/PostCtrls'
|
||||||
import {PostEmbeds, PostEmbedViewContext} from '#/view/com/util/post-embeds'
|
import {PostEmbeds, PostEmbedViewContext} from '#/view/com/util/post-embeds'
|
||||||
import {PostMeta} from '#/view/com/util/PostMeta'
|
import {PostMeta} from '#/view/com/util/PostMeta'
|
||||||
import {TREE_AVI_WIDTH, TREE_INDENT} from '#/screens/PostThread/const'
|
import {
|
||||||
|
OUTER_SPACE,
|
||||||
|
REPLY_LINE_WIDTH,
|
||||||
|
TREE_AVI_WIDTH,
|
||||||
|
TREE_INDENT,
|
||||||
|
} from '#/screens/PostThread/const'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
||||||
import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash'
|
import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash'
|
||||||
@@ -175,6 +180,8 @@ let PostThreadItemLoaded = ({
|
|||||||
setLimitLines(false)
|
setLimitLines(false)
|
||||||
}, [setLimitLines])
|
}, [setLimitLines])
|
||||||
|
|
||||||
|
const indents = Math.max(0, item.ui.indent - 1)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
@@ -185,13 +192,16 @@ let PostThreadItemLoaded = ({
|
|||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
],
|
],
|
||||||
]}>
|
]}>
|
||||||
{Array.from(Array(item.ui.indent - 1)).map((_, n: number) => (
|
{Array.from(Array(indents)).map((_, n: number) => (
|
||||||
<View
|
<View
|
||||||
key={`${post.uri}-padding-${n}`}
|
key={`${post.uri}-padding-${n}`}
|
||||||
style={[
|
style={[
|
||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
{
|
{
|
||||||
borderRightWidth: 2,
|
borderRightWidth:
|
||||||
|
item.ui.isDeadEnd && n === indents - 1 && !item.ui.hasReadMore
|
||||||
|
? 0
|
||||||
|
: REPLY_LINE_WIDTH,
|
||||||
width: TREE_INDENT + TREE_AVI_WIDTH / 2,
|
width: TREE_INDENT + TREE_AVI_WIDTH / 2,
|
||||||
left: 1,
|
left: 1,
|
||||||
},
|
},
|
||||||
@@ -202,13 +212,35 @@ let PostThreadItemLoaded = ({
|
|||||||
<SubtleHover>
|
<SubtleHover>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.px_lg,
|
{
|
||||||
a.pt_sm,
|
paddingHorizontal: OUTER_SPACE,
|
||||||
|
paddingTop: OUTER_SPACE / 2,
|
||||||
|
},
|
||||||
item.ui.indent === 1 && [
|
item.ui.indent === 1 && [
|
||||||
!item.ui.showParentReplyLine && a.pt_lg,
|
!item.ui.showParentReplyLine && a.pt_lg,
|
||||||
!item.ui.showChildReplyLine && a.pb_sm,
|
!item.ui.showChildReplyLine && a.pb_sm,
|
||||||
],
|
],
|
||||||
]}>
|
]}>
|
||||||
|
{item.ui.indent > 1 && (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.absolute,
|
||||||
|
t.atoms.border_contrast_low,
|
||||||
|
{
|
||||||
|
left: -1,
|
||||||
|
top: 0,
|
||||||
|
height:
|
||||||
|
TREE_AVI_WIDTH / 2 +
|
||||||
|
REPLY_LINE_WIDTH / 2 +
|
||||||
|
OUTER_SPACE / 2,
|
||||||
|
width: OUTER_SPACE,
|
||||||
|
borderLeftWidth: REPLY_LINE_WIDTH,
|
||||||
|
borderBottomWidth: REPLY_LINE_WIDTH,
|
||||||
|
borderBottomLeftRadius: a.rounded_sm.borderRadius,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<PostHider
|
<PostHider
|
||||||
testID={`postThreadItem-by-${post.author.handle}`}
|
testID={`postThreadItem-by-${post.author.handle}`}
|
||||||
href={postHref}
|
href={postHref}
|
||||||
|
|||||||
@@ -56,7 +56,19 @@ export function flatten(
|
|||||||
if (item.depth <= deepestParent.depth) {
|
if (item.depth <= deepestParent.depth) {
|
||||||
for (let pi = parents.length - 1; pi >= 0; pi--) {
|
for (let pi = parents.length - 1; pi >= 0; pi--) {
|
||||||
const parent = parents[pi]
|
const parent = parents[pi]
|
||||||
|
|
||||||
if (item.depth <= parent.depth) {
|
if (item.depth <= parent.depth) {
|
||||||
|
/*
|
||||||
|
* Find the previous post item and set the `hasReadMore` flag
|
||||||
|
*/
|
||||||
|
for (let ui = i - 1; ui >= 0; ui--) {
|
||||||
|
let prev = flattened[ui]
|
||||||
|
if (prev.type === 'threadPost') {
|
||||||
|
prev.ui.hasReadMore = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
flattened.splice(
|
flattened.splice(
|
||||||
i + 1 + (pi - parents.length),
|
i + 1 + (pi - parents.length),
|
||||||
0,
|
0,
|
||||||
@@ -94,6 +106,17 @@ export function flatten(
|
|||||||
for (let pi = parents.length - 1; pi >= 0; pi--) {
|
for (let pi = parents.length - 1; pi >= 0; pi--) {
|
||||||
const parent = parents[pi]
|
const parent = parents[pi]
|
||||||
if (parent.depth <= item.depth) {
|
if (parent.depth <= item.depth) {
|
||||||
|
/*
|
||||||
|
* Find the previous post item and set the `hasReadMore` flag
|
||||||
|
*/
|
||||||
|
for (let ui = i; ui >= 0; ui--) {
|
||||||
|
let prev = flattened[ui]
|
||||||
|
if (prev.type === 'threadPost') {
|
||||||
|
prev.ui.hasReadMore = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
flattened.splice(
|
flattened.splice(
|
||||||
i + 2 + (pi - parents.length),
|
i + 2 + (pi - parents.length),
|
||||||
0,
|
0,
|
||||||
@@ -118,7 +141,7 @@ export function flatten(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(flattened)
|
// console.log(flattened)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert hidden items and buttons to show them
|
* Insert hidden items and buttons to show them
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ export type Slice =
|
|||||||
showChildReplyLine: boolean
|
showChildReplyLine: boolean
|
||||||
indent: number
|
indent: number
|
||||||
parentHasBranchingReplies: boolean
|
parentHasBranchingReplies: boolean
|
||||||
|
isDeadEnd: boolean
|
||||||
|
hasReadMore?: boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ export function threadPost({
|
|||||||
depth,
|
depth,
|
||||||
value,
|
value,
|
||||||
oneUp,
|
oneUp,
|
||||||
|
oneDown,
|
||||||
moderationOpts,
|
moderationOpts,
|
||||||
traversalMetadata,
|
traversalMetadata,
|
||||||
}: {
|
}: {
|
||||||
@@ -104,6 +105,7 @@ export function threadPost({
|
|||||||
? depth
|
? depth
|
||||||
: traversalMetadata?.indent || depth,
|
: traversalMetadata?.indent || depth,
|
||||||
parentHasBranchingReplies: !!traversalMetadata?.hasBranchingReplies,
|
parentHasBranchingReplies: !!traversalMetadata?.hasBranchingReplies,
|
||||||
|
isDeadEnd: !oneDown || oneDown?.depth < depth,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user