Skip to content

Commit

Permalink
Use URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
vcarl committed Feb 11, 2025
1 parent c777b9a commit 6bfe125
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/view/com/post-thread/PostThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,24 +257,24 @@ export function PostThread({uri}: {uri: string | undefined}) {
randomCache,
])

const [collapsedCIDs, setCollapsedCIDs] = React.useState(new Set())
const descendantsOfCollapsedCIDs = React.useMemo(() => {
const [collapsedURIs, setCollapsedURIs] = React.useState(new Set())
const descendantsOfCollapsedURIs = React.useMemo(() => {
const set = new Set<string>()
if (!skeleton) return set

for (let val of skeleton.replies) {
if (!isThreadPost(val)) continue
if (collapsedCIDs.has(val.post.cid) || set.has(val.post.cid)) {
if (collapsedURIs.has(val.post.uri) || set.has(val.post.uri)) {
val.replies?.forEach(r => {
isThreadPost(r) && set.add(r.post.cid)
isThreadPost(r) && set.add(r.post.uri)
})
}
}
return set
}, [collapsedCIDs, skeleton])
const toggleCollapse = React.useCallback((cid: string) => {
setCollapsedCIDs(x => {
x.has(cid) ? x.delete(cid) : x.add(cid)
}, [collapsedURIs, skeleton])
const toggleCollapse = React.useCallback((collapseUri: string) => {
setCollapsedURIs(x => {
x.has(collapseUri) ? x.delete(collapseUri) : x.add(collapseUri)
return new Set(x)
})
}, [])
Expand Down Expand Up @@ -511,8 +511,8 @@ export function PostThread({uri}: {uri: string | undefined}) {
ref={item.ctx.isHighlightedPost ? highlightedPostRef : undefined}
onLayout={deferParents ? () => setDeferParents(false) : undefined}>
<PostThreadItem
isCollapsed={collapsedCIDs.has(item.post.cid)}
isUnderCollapsed={descendantsOfCollapsedCIDs.has(item.post.cid)}
isCollapsed={collapsedURIs.has(item.post.uri)}
isUnderCollapsed={descendantsOfCollapsedURIs.has(item.post.uri)}
onCollapse={treeView ? toggleCollapse : NO_OP}
post={item.post}
record={item.record}
Expand Down
10 changes: 5 additions & 5 deletions src/view/com/post-thread/PostThreadItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function PostThreadItem({
}: {
isCollapsed: boolean
isUnderCollapsed: boolean
onCollapse: (cid: string) => void
onCollapse: (uri: string) => void
post: AppBskyFeedDefs.PostView
record: AppBskyFeedPost.Record
moderation: ModerationDecision | undefined
Expand Down Expand Up @@ -188,7 +188,7 @@ let PostThreadItemLoaded = ({
}: {
isCollapsed: boolean
isUnderCollapsed: boolean
onCollapse: (cid: string) => void
onCollapse: (uri: string) => void
post: Shadow<AppBskyFeedDefs.PostView>
record: AppBskyFeedPost.Record
richText: RichTextAPI
Expand Down Expand Up @@ -510,7 +510,7 @@ let PostThreadItemLoaded = ({
testID={`postThreadItem-by-${post.author.handle}`}
href={postHref}
onLongPress={() => {
onCollapse(post.cid)
onCollapse(post.uri)
}}
disabled={overrideBlur}
modui={moderation.ui('contentList')}
Expand Down Expand Up @@ -549,7 +549,7 @@ let PostThreadItemLoaded = ({
testID={`postThreadItem-by-${post.author.handle}`}
href={postHref}
onLongPress={() => {
onCollapse(post.cid)
onCollapse(post.uri)
}}
disabled={overrideBlur}
modui={moderation.ui('contentList')}
Expand Down Expand Up @@ -643,7 +643,7 @@ let PostThreadItemLoaded = ({
enableTags
value={richText}
onLinkLongPress={() => {
onCollapse(post.cid)
onCollapse(post.uri)
}}
style={[a.flex_1, a.text_md]}
numberOfLines={limitLines ? MAX_POST_LINES : undefined}
Expand Down

0 comments on commit 6bfe125

Please sign in to comment.