diff options
author | Eric Bailey <git@esb.lol> | 2024-08-23 14:35:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-23 12:35:48 -0700 |
commit | 425dd5f27feade1abff7a8e882929ca112376210 (patch) | |
tree | 4a279fe3f60b65a6f5c9774adb6e4d36ba1b046f /src/view/com/post-thread/PostThreadItem.tsx | |
parent | 5ec8761b294b6a650af9ee286df6864d6fc4f25d (diff) | |
download | voidsky-425dd5f27feade1abff7a8e882929ca112376210.tar.zst |
Optimistic hidden replies (#4977)
Diffstat (limited to 'src/view/com/post-thread/PostThreadItem.tsx')
-rw-r--r-- | src/view/com/post-thread/PostThreadItem.tsx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index f2cd8e85a..f2a8be598 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -17,6 +17,7 @@ import {useLanguagePrefs} from '#/state/preferences' import {useOpenLink} from '#/state/preferences/in-app-browser' import {ThreadPost} from '#/state/queries/post-thread' import {useComposerControls} from '#/state/shell/composer' +import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies' import {MAX_POST_LINES} from 'lib/constants' import {usePalette} from 'lib/hooks/usePalette' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' @@ -206,24 +207,22 @@ let PostThreadItemLoaded = ({ return makeProfileLink(post.author, 'post', urip.rkey, 'reposted-by') }, [post.uri, post.author]) const repostsTitle = _(msg`Reposts of this post`) + const threadgateHiddenReplies = useMergedThreadgateHiddenReplies({ + threadgateRecord, + }) const additionalPostAlerts: AppModerationCause[] = React.useMemo(() => { - const isPostHiddenByThreadgate = threadgateRecord?.hiddenReplies?.includes( - post.uri, - ) - const isControlledByViewer = - threadgateRecord && - new AtUri(threadgateRecord.post).host === currentAccount?.did - if (!isControlledByViewer) return [] - return threadgateRecord && isPostHiddenByThreadgate + const isPostHiddenByThreadgate = threadgateHiddenReplies.has(post.uri) + const isControlledByViewer = new AtUri(rootUri).host === currentAccount?.did + return isControlledByViewer && isPostHiddenByThreadgate ? [ { type: 'reply-hidden', - source: {type: 'user', did: new AtUri(threadgateRecord.post).host}, + source: {type: 'user', did: currentAccount?.did}, priority: 6, }, ] : [] - }, [post, threadgateRecord, currentAccount?.did]) + }, [post, currentAccount?.did, threadgateHiddenReplies, rootUri]) const quotesHref = React.useMemo(() => { const urip = new AtUri(post.uri) return makeProfileLink(post.author, 'post', urip.rkey, 'quotes') |