From f769564edfea3ec6406c49ef639685d942e14e09 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 24 Jun 2024 10:11:43 -0700 Subject: [PATCH] Remove the 'Who can reply' element except when viewing root, and add "edit" (#4615) * Remove the 'Who can reply' element except when viewing root, and add the edit text to authors * Switch to icon --- .../threadgate => components}/WhoCanReply.tsx | 95 +----- src/view/com/post-thread/PostThreadItem.tsx | 307 +++++++++--------- 2 files changed, 165 insertions(+), 237 deletions(-) rename src/{view/com/threadgate => components}/WhoCanReply.tsx (79%) diff --git a/src/view/com/threadgate/WhoCanReply.tsx b/src/components/WhoCanReply.tsx similarity index 79% rename from src/view/com/threadgate/WhoCanReply.tsx rename to src/components/WhoCanReply.tsx index 3f9970f5fb..cd171a0a46 100644 --- a/src/view/com/threadgate/WhoCanReply.tsx +++ b/src/components/WhoCanReply.tsx @@ -33,7 +33,8 @@ import {CircleBanSign_Stroke2_Corner0_Rounded as CircleBanSign} from '#/componen import {Earth_Stroke2_Corner0_Rounded as Earth} from '#/components/icons/Globe' import {Group3_Stroke2_Corner0_Rounded as Group} from '#/components/icons/Group' import {Text} from '#/components/Typography' -import {TextLink} from '../util/Link' +import {TextLink} from '../view/com/util/Link' +import {PencilLine_Stroke2_Corner0_Rounded as PencilLine} from './icons/Pencil' interface WhoCanReplyProps { post: AppBskyFeedDefs.PostView @@ -41,11 +42,7 @@ interface WhoCanReplyProps { style?: StyleProp } -export function WhoCanReplyInline({ - post, - isThreadAuthor, - style, -}: WhoCanReplyProps) { +export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) { const {_} = useLingui() const t = useTheme() const infoDialogControl = useDialogControl() @@ -90,73 +87,13 @@ export function WhoCanReplyInline({ ]}> {description} + {isThreadAuthor && ( + + )} )} - - - ) -} - -export function WhoCanReplyBlock({ - post, - isThreadAuthor, - style, -}: WhoCanReplyProps) { - const {_} = useLingui() - const t = useTheme() - const infoDialogControl = useDialogControl() - const {settings, isRootPost, onPressEdit} = useWhoCanReply(post) - - if (!isRootPost) { - return null - } - if (!settings.length && !isThreadAuthor) { - return null - } - - const isEverybody = settings.length === 0 - const isNobody = !!settings.find(gate => gate.type === 'nobody') - const description = isEverybody - ? _(msg`Everybody can reply`) - : isNobody - ? _(msg`Replies on this thread are disabled`) - : _(msg`Some people can reply`) - - return ( - <> - - + ) } @@ -176,31 +113,24 @@ function Icon({ return } -function InfoDialog({ +export function WhoCanReplyDialog({ control, post, - settings, }: { control: Dialog.DialogControlProps post: AppBskyFeedDefs.PostView - settings: ThreadgateSetting[] }) { return ( - + ) } -function InfoDialogInner({ - post, - settings, -}: { - post: AppBskyFeedDefs.PostView - settings: ThreadgateSetting[] -}) { +function WhoCanReplyDialogInner({post}: {post: AppBskyFeedDefs.PostView}) { const {_} = useLingui() + const {settings} = useWhoCanReply(post) return ( - - - - - {!isThreadedChild && showParentReplyLine && ( + + + + + {!isThreadedChild && showParentReplyLine && ( + + )} + + + + + {/* If we are in threaded mode, the avatar is rendered in PostMeta */} + {!isThreadedChild && ( + + + + {showChildReplyLine && ( )} - + )} - {/* If we are in threaded mode, the avatar is rendered in PostMeta */} - {!isThreadedChild && ( - - + + + + {richText?.text ? ( + + - - {showChildReplyLine && ( - - )} + + ) : undefined} + {limitLines ? ( + + ) : undefined} + {post.embed && ( + + )} - - - - - - {richText?.text ? ( - - - - ) : undefined} - {limitLines ? ( - - ) : undefined} - {post.embed && ( - - - - )} - - + - {hasMore ? ( - - - More - - - - ) : undefined} - - - - + + {hasMore ? ( + + + More + + + + ) : undefined} + + ) } } @@ -671,7 +666,7 @@ function ExpandedPostDetails({ s.mb10, ]}> {niceDate(post.indexedAt)} - + {needsTranslation && ( <> ·