From 4f0f9eb4139a8c3439be0125ffd982b3cbf5c9b5 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Nov 2024 22:05:51 +0000 Subject: Fix TagMenu initial render perf (#6483) * Split tag menu dialog content * Log the actual error please * Fix it on native --- src/components/TagMenu/index.tsx | 314 ++++++++++++++++++++------------------- 1 file changed, 164 insertions(+), 150 deletions(-) (limited to 'src/components/TagMenu/index.tsx') diff --git a/src/components/TagMenu/index.tsx b/src/components/TagMenu/index.tsx index ae9fcdae2..310ecc4c2 100644 --- a/src/components/TagMenu/index.tsx +++ b/src/components/TagMenu/index.tsx @@ -40,9 +40,37 @@ export function TagMenu({ tag: string authorHandle?: string }>) { + const navigation = useNavigation() + return ( + <> + {children} + + + + + + ) +} + +function TagMenuInner({ + control, + tag, + authorHandle, + navigation, +}: { + control: Dialog.DialogOuterProps['control'] + tag: string + authorHandle?: string + // Passed down because on native, we don't use real portals (and context would be wrong). + navigation: NavigationProp +}) { const {_} = useLingui() const t = useTheme() - const navigation = useNavigation() const {isLoading: isPreferencesLoading, data: preferences} = usePreferencesQuery() const { @@ -79,32 +107,75 @@ export function TagMenu({ }, [tag, preferences?.moderationPrefs?.mutedWords]) return ( - <> - {children} - - - - - {isPreferencesLoading ? ( - - - - ) : ( - <> + + {isPreferencesLoading ? ( + + + + ) : ( + <> + + { + control.close(() => { + navigation.push('Hashtag', { + tag: encodeURIComponent(tag), + }) + }) + })}> + + + + See{' '} + + {displayTag} + {' '} + posts + + + + + + {authorHandle && !isInvalidHandle(authorHandle) && ( + <> + + { control.close(() => { navigation.push('Hashtag', { tag: encodeURIComponent(tag), + author: authorHandle, }) }) })}> @@ -118,7 +189,7 @@ export function TagMenu({ a.px_lg, a.py_md, ]}> - + {displayTag} {' '} - posts + posts by this user + + )} - {authorHandle && !isInvalidHandle(authorHandle) && ( - <> - - - { - control.close(() => { - navigation.push('Hashtag', { - tag: encodeURIComponent(tag), - author: authorHandle, - }) - }) - })}> - - - - - See{' '} - - {displayTag} - {' '} - posts by this user - - - - - - )} - - {preferences ? ( - <> - + {preferences ? ( + <> + - - - ) : null} - + }) + }}> + + + + {isMuted ? _(msg`Unmute`) : _(msg`Mute`)}{' '} + + {displayTag} + {' '} + posts + + + + + ) : null} + - - - )} - - - + + + )} + ) } -- cgit 1.4.1