Skip to content

Commit c8004f4

Browse files
capJavertclaude
andauthored
fix: don't request tag chip feeds until onboarding is complete (#6330)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2e7076c commit c8004f4

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

packages/shared/src/hooks/feed/useFeeds.spec.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ import {
1414
import { mockGraphQL } from '../../../__tests__/helpers/graphql';
1515
import { BootApp } from '../../lib/boot';
1616
import { GrowthBookProvider } from '../../components/GrowthBookProvider';
17+
import { useOnboardingActions } from '../auth/useOnboardingActions';
18+
19+
jest.mock('../auth/useOnboardingActions', () => ({
20+
useOnboardingActions: jest.fn(),
21+
}));
22+
23+
const mockUseOnboardingActions = useOnboardingActions as jest.Mock;
1724

1825
const client = new QueryClient();
1926
const noop = jest.fn();
@@ -82,6 +89,7 @@ const feeds = [
8289
describe('useFeeds hook', () => {
8390
beforeEach(() => {
8491
client.clear();
92+
mockUseOnboardingActions.mockReturnValue({ isOnboardingComplete: true });
8593

8694
mockGraphQL({
8795
request: {
@@ -251,4 +259,34 @@ describe('useFeeds hook', () => {
251259
result.current.feeds!.edges.find((f) => f.node.id === 'cf1'),
252260
).toBeFalsy();
253261
});
262+
263+
it('should not request tag chip feeds until onboarding is complete', async () => {
264+
mockUseOnboardingActions.mockReturnValue({ isOnboardingComplete: false });
265+
266+
let withoutChipsCalled = false;
267+
mockGraphQL({
268+
request: {
269+
query: FEED_LIST_QUERY,
270+
variables: {
271+
includeTagChipFeeds: false,
272+
},
273+
},
274+
result: () => {
275+
withoutChipsCalled = true;
276+
277+
return {
278+
data: {
279+
feedList: {
280+
pageInfo: { endCursor: expect.any(String), hasNextPage: false },
281+
edges: feeds,
282+
},
283+
},
284+
};
285+
},
286+
});
287+
288+
renderHook(() => useFeeds(), { wrapper: Wrapper });
289+
290+
await waitFor(() => expect(withoutChipsCalled).toBe(true));
291+
});
254292
});

packages/shared/src/hooks/feed/useFeeds.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
FeedChipsVariant,
1818
featureFeedChips,
1919
} from '../../lib/featureManagement';
20+
import { useOnboardingActions } from '../auth/useOnboardingActions';
2021

2122
export type CreateFeedProps = {
2223
name: string;
@@ -38,13 +39,18 @@ export const useFeeds = (): UseFeeds => {
3839
const queryClient = useQueryClient();
3940
const { displayToast } = useToastNotification();
4041
const { user, feeds: bootFeeds } = useAuthContext();
41-
const queryKey = generateQueryKey(RequestKey.Feeds, user);
42+
const { isOnboardingComplete } = useOnboardingActions();
4243

4344
const { value: feedChipsVariant } = useConditionalFeature({
4445
feature: featureFeedChips,
4546
shouldEvaluate: !!user,
4647
});
47-
const includeTagChipFeeds = feedChipsVariant === FeedChipsVariant.V2;
48+
const includeTagChipFeeds =
49+
feedChipsVariant === FeedChipsVariant.V2 && isOnboardingComplete;
50+
51+
const queryKey = generateQueryKey(RequestKey.Feeds, user, {
52+
includeTagChipFeeds,
53+
});
4854

4955
const initialData: FeedList['feedList'] | undefined = useMemo(() => {
5056
if (!bootFeeds) {

0 commit comments

Comments
 (0)