Refactor GrowthHack to always render on iOS with enabled prop (#9723)
Drill down an `enabled` prop to ThreadItemAnchorFollowButtonInner so that the GrowthHack wrapper is always rendered on iOS, even when the follow button shouldn't be displayed. The inner component returns null when disabled, allowing GrowthHack to render its logo without children. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,24 +19,36 @@ import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/
|
||||
import {IS_IOS} from '#/env'
|
||||
import {GrowthHack} from './GrowthHack'
|
||||
|
||||
export function ThreadItemAnchorFollowButton({did}: {did: string}) {
|
||||
export function ThreadItemAnchorFollowButton({
|
||||
did,
|
||||
enabled = true,
|
||||
}: {
|
||||
did: string
|
||||
enabled?: boolean
|
||||
}) {
|
||||
if (IS_IOS) {
|
||||
return (
|
||||
<GrowthHack>
|
||||
<ThreadItemAnchorFollowButtonInner did={did} />
|
||||
<ThreadItemAnchorFollowButtonInner did={did} enabled={enabled} />
|
||||
</GrowthHack>
|
||||
)
|
||||
}
|
||||
|
||||
return <ThreadItemAnchorFollowButtonInner did={did} />
|
||||
return <ThreadItemAnchorFollowButtonInner did={did} enabled={enabled} />
|
||||
}
|
||||
|
||||
export function ThreadItemAnchorFollowButtonInner({did}: {did: string}) {
|
||||
export function ThreadItemAnchorFollowButtonInner({
|
||||
did,
|
||||
enabled = true,
|
||||
}: {
|
||||
did: string
|
||||
enabled?: boolean
|
||||
}) {
|
||||
const {data: profile, isLoading} = useProfileQuery({did})
|
||||
|
||||
// We will never hit this - the profile will always be cached or loaded above
|
||||
// but it keeps the typechecker happy
|
||||
if (isLoading || !profile) return null
|
||||
if (!enabled || isLoading || !profile) return null
|
||||
|
||||
return <PostThreadFollowBtnLoaded profile={profile} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user