({
feedSettings,
userId,
headline,
requiredTags = REQUIRED_TAGS_THRESHOLD,
hidePreview,
featuredTags,
isOnboarding,
}: EditTagProps)
| 36 | isOnboarding?: boolean; |
| 37 | } |
| 38 | export const EditTag = ({ |
| 39 | feedSettings, |
| 40 | userId, |
| 41 | headline, |
| 42 | requiredTags = REQUIRED_TAGS_THRESHOLD, |
| 43 | hidePreview, |
| 44 | featuredTags, |
| 45 | isOnboarding, |
| 46 | }: EditTagProps): ReactElement => { |
| 47 | const isMobile = useViewSize(ViewSize.MobileL); |
| 48 | const [isPreviewVisible, setPreviewVisible] = useState(false); |
| 49 | const tagsCount = feedSettings?.includeTags?.length || 0; |
| 50 | const isPreviewEnabled = tagsCount >= requiredTags; |
| 51 | |
| 52 | const [searchQuery, setSearchQuery] = useState<string>(''); |
| 53 | const [onSearch] = useDebounceFn((value?: string) => { |
| 54 | setSearchQuery(value ?? ''); |
| 55 | }, 350); |
| 56 | |
| 57 | const { data: searchResult } = useTagSearch({ |
| 58 | value: searchQuery, |
| 59 | origin: Origin.EditTag, |
| 60 | }); |
| 61 | const searchTags = searchResult?.searchTags.tags || []; |
| 62 | |
| 63 | const { value: showPersonas } = useConditionalFeature({ |
| 64 | feature: featureOnboardingPersonas, |
| 65 | shouldEvaluate: !!feedSettings, |
| 66 | }); |
| 67 | |
| 68 | const tagsRef = useRef<HTMLDivElement>(null); |
| 69 | const hasScrolledToTagsRef = useRef(false); |
| 70 | |
| 71 | useEffect(() => { |
| 72 | if (!isMobile || !showPersonas) { |
| 73 | return undefined; |
| 74 | } |
| 75 | return subscribePersonaSelection(() => { |
| 76 | if (hasScrolledToTagsRef.current) { |
| 77 | return; |
| 78 | } |
| 79 | hasScrolledToTagsRef.current = true; |
| 80 | tagsRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' }); |
| 81 | }); |
| 82 | }, [isMobile, showPersonas]); |
| 83 | |
| 84 | // When the persona feature is on, override any caller-supplied headline |
| 85 | // (Freyja funnel JSON) with the persona-tuned copy. |
| 86 | // TODO: drop this override once Freyja's persona-experiment variant ships |
| 87 | // the new headline directly. |
| 88 | const resolvedHeadline = showPersonas |
| 89 | ? 'Tune your feed' |
| 90 | : headline || 'Pick tags that are relevant to you'; |
| 91 | |
| 92 | return ( |
| 93 | <> |
| 94 | {isOnboarding ? ( |
| 95 | <OnboardingHeadline>{resolvedHeadline}</OnboardingHeadline> |
nothing calls this directly
no test coverage detected