From 0b38c77faa71dbc777d3d0162b86cb3e8695ff99 Mon Sep 17 00:00:00 2001 From: dan Date: Sun, 17 Nov 2024 21:06:22 +0000 Subject: Revert "Render dropdown menu items lazily (#6437)" (#6470) This reverts commit e9fe8d90ef5e9ca2ed4bc9649794c5288fb1232d. --- src/view/com/util/forms/PostDropdownBtn.tsx | 587 +++++++++++++--------------- 1 file changed, 278 insertions(+), 309 deletions(-) (limited to 'src') diff --git a/src/view/com/util/forms/PostDropdownBtn.tsx b/src/view/com/util/forms/PostDropdownBtn.tsx index e71332279..1cd4841a5 100644 --- a/src/view/com/util/forms/PostDropdownBtn.tsx +++ b/src/view/com/util/forms/PostDropdownBtn.tsx @@ -102,77 +102,12 @@ let PostDropdownBtn = ({ timestamp: string threadgateRecord?: AppBskyFeedThreadgate.Record }): React.ReactNode => { + const {hasSession, currentAccount} = useSession() const theme = useTheme() const alf = useAlf() - const {_} = useLingui() - const defaultCtrlColor = theme.palette.default.postCtrl - return ( - - - - {({props, state}) => { - return ( - - - - ) - }} - - - - - - - ) -} - -PostDropdownBtn = memo(PostDropdownBtn) -export {PostDropdownBtn} - -let PostDropdownMenuItems = ({ - post, - postFeedContext, - record, - richText, - timestamp, - threadgateRecord, -}: { - testID: string - post: Shadow - postFeedContext: string | undefined - record: AppBskyFeedPost.Record - richText: RichTextAPI - style?: StyleProp - hitSlop?: PressableProps['hitSlop'] - size?: 'lg' | 'md' | 'sm' - timestamp: string - threadgateRecord?: AppBskyFeedThreadgate.Record -}): React.ReactNode => { - const {hasSession, currentAccount} = useSession() const {gtMobile} = useBreakpoints() const {_} = useLingui() + const defaultCtrlColor = theme.palette.default.postCtrl const langPrefs = useLanguagePrefs() const {mutateAsync: deletePostMutate} = usePostDeleteMutation() const {mutateAsync: pinPostMutate, isPending: isPinPending} = @@ -425,276 +360,308 @@ let PostDropdownMenuItems = ({ }, [isPinned, pinPostMutate, postCid, postUri]) return ( - <> - {isAuthor && ( - <> - - - - {isPinned - ? _(msg`Unpin from profile`) - : _(msg`Pin to your profile`)} - - - - - - - )} - - - {(!hideInPWI || hasSession) && ( - <> - - {_(msg`Translate`)} - - - - - {_(msg`Copy post text`)} - - - - )} - - {hasSession && ( - sendViaChatControl.open()}> - - Send via direct message - - - - )} + + + + {({props, state}) => { + return ( + + + + ) + }} + - { - if (showLoggedOutWarning) { - loggedOutWarningPromptControl.open() - } else { - onSharePost() - } - }}> - - {isWeb ? _(msg`Copy link to post`) : _(msg`Share`)} - - - - - {canEmbed && ( - embedPostControl.open()}> - {_(msg`Embed post`)} - - - )} - + + {isAuthor && ( + <> + + + + {isPinned + ? _(msg`Unpin from profile`) + : _(msg`Pin to your profile`)} + + + + + + + )} - {hasSession && feedFeedback.enabled && ( - <> - - - {_(msg`Show more like this`)} - - + {(!hideInPWI || hasSession) && ( + <> + + {_(msg`Translate`)} + + - - {_(msg`Show less like this`)} - - - - - )} + + {_(msg`Copy post text`)} + + + + )} + + {hasSession && ( + sendViaChatControl.open()}> + + Send via direct message + + + + )} - {hasSession && ( - <> - - + testID="postDropdownShareBtn" + label={isWeb ? _(msg`Copy link to post`) : _(msg`Share`)} + onPress={() => { + if (showLoggedOutWarning) { + loggedOutWarningPromptControl.open() + } else { + onSharePost() + } + }}> - {isThreadMuted ? _(msg`Unmute thread`) : _(msg`Mute thread`)} + {isWeb ? _(msg`Copy link to post`) : _(msg`Share`)} - + - mutedWordsDialogControl.open()}> - {_(msg`Mute words & tags`)} - - + {canEmbed && ( + embedPostControl.open()}> + {_(msg`Embed post`)} + + + )} - - )} - {hasSession && - (canHideReplyForEveryone || canDetachQuote || canHidePostForMe) && ( - <> - - - {canHidePostForMe && ( + {hasSession && feedFeedback.enabled && ( + <> + + hidePromptControl.open()}> - - {isReply - ? _(msg`Hide reply for me`) - : _(msg`Hide post for me`)} - - + testID="postDropdownShowMoreBtn" + label={_(msg`Show more like this`)} + onPress={onPressShowMore}> + {_(msg`Show more like this`)} + - )} - {canHideReplyForEveryone && ( + hideReplyConfirmControl.open() - }> - - {isReplyHiddenByThreadgate - ? _(msg`Show reply for everyone`) - : _(msg`Hide reply for everyone`)} - - + testID="postDropdownShowLessBtn" + label={_(msg`Show less like this`)} + onPress={onPressShowLess}> + {_(msg`Show less like this`)} + - )} - - {canDetachQuote && ( + + + )} + + {hasSession && ( + <> + + quotePostDetachConfirmControl.open() - }> + onPress={onToggleThreadMute}> - {quoteEmbed.isDetached - ? _(msg`Re-attach quote`) - : _(msg`Detach quote`)} + {isThreadMuted + ? _(msg`Unmute thread`) + : _(msg`Mute thread`)} - )} - - - )} - {hasSession && ( - <> - - - {!isAuthor && ( - reportDialogControl.open()}> - {_(msg`Report post`)} - - - )} - - {isAuthor && ( - <> postInteractionSettingsDialogControl.open()} - {...(isAuthor - ? Platform.select({ - web: { - onHoverIn: prefetchPostInteractionSettings, - }, - native: { - onPressIn: prefetchPostInteractionSettings, - }, - }) - : {})}> - - {_(msg`Edit interaction settings`)} - - - - deletePromptControl.open()}> - {_(msg`Delete post`)} - + testID="postDropdownMuteWordsBtn" + label={_(msg`Mute words & tags`)} + onPress={() => mutedWordsDialogControl.open()}> + {_(msg`Mute words & tags`)} + + + + )} + + {hasSession && + (canHideReplyForEveryone || canDetachQuote || canHidePostForMe) && ( + <> + + + {canHidePostForMe && ( + hidePromptControl.open()}> + + {isReply + ? _(msg`Hide reply for me`) + : _(msg`Hide post for me`)} + + + + )} + {canHideReplyForEveryone && ( + hideReplyConfirmControl.open() + }> + + {isReplyHiddenByThreadgate + ? _(msg`Show reply for everyone`) + : _(msg`Hide reply for everyone`)} + + + + )} + + {canDetachQuote && ( + quotePostDetachConfirmControl.open() + }> + + {quoteEmbed.isDetached + ? _(msg`Re-attach quote`) + : _(msg`Detach quote`)} + + + + )} + )} - - - )} + + {hasSession && ( + <> + + + {!isAuthor && ( + reportDialogControl.open()}> + {_(msg`Report post`)} + + + )} + + {isAuthor && ( + <> + + postInteractionSettingsDialogControl.open() + } + {...(isAuthor + ? Platform.select({ + web: { + onHoverIn: prefetchPostInteractionSettings, + }, + native: { + onPressIn: prefetchPostInteractionSettings, + }, + }) + : {})}> + + {_(msg`Edit interaction settings`)} + + + + deletePromptControl.open()}> + {_(msg`Delete post`)} + + + + )} + + + )} + + - + ) } -PostDropdownMenuItems = memo(PostDropdownMenuItems) + +PostDropdownBtn = memo(PostDropdownBtn) +export {PostDropdownBtn} -- cgit 1.4.1