({ onSettled }: ShellStateRequestProps)
| 66 | left.tagChipSeedStrategy === right.tagChipSeedStrategy; |
| 67 | |
| 68 | const ShellStateRequest = ({ onSettled }: ShellStateRequestProps): null => { |
| 69 | const client = useQueryClient(); |
| 70 | const { user } = useAuthContext(); |
| 71 | const { requestMethod } = useRequestProtocol(); |
| 72 | const variables = useFeedListVariables(); |
| 73 | const variablesRef = useRef(variables); |
| 74 | variablesRef.current = variables; |
| 75 | const { value: feedChipsVariant } = useConditionalFeature({ |
| 76 | feature: featureFeedChips, |
| 77 | shouldEvaluate: !!user, |
| 78 | }); |
| 79 | const feedChipsVariantRef = useRef(feedChipsVariant); |
| 80 | feedChipsVariantRef.current = feedChipsVariant; |
| 81 | |
| 82 | const { isFetched } = useQuery({ |
| 83 | queryKey: generateQueryKey(RequestKey.ShellState, user), |
| 84 | queryFn: async () => { |
| 85 | const feedListVariables = variablesRef.current; |
| 86 | const data = await requestMethod<ShellStateData>( |
| 87 | SHELL_STATE_QUERY, |
| 88 | feedListVariables, |
| 89 | ); |
| 90 | |
| 91 | client.setQueryData(generateQueryKey(RequestKey.Actions, user), { |
| 92 | actions: data.actions, |
| 93 | serverLoaded: true, |
| 94 | }); |
| 95 | client.setQueryData( |
| 96 | generateQueryKey(RequestKey.UserStreak, user), |
| 97 | data.userStreak, |
| 98 | ); |
| 99 | client.setQueryData( |
| 100 | dmRequestCountQueryKey(user), |
| 101 | data.directMessageRequestCount, |
| 102 | ); |
| 103 | client.setQueryData( |
| 104 | lfgWaitingCountQueryKey(user), |
| 105 | data.lfgReachOutWaitingCount, |
| 106 | ); |
| 107 | // The mock counts its own made-up conversations instead. |
| 108 | if (!isDmMockMode) { |
| 109 | client.setQueryData( |
| 110 | dmUnreadCountQueryKey(user), |
| 111 | data.directMessageUnreadCount, |
| 112 | ); |
| 113 | } |
| 114 | |
| 115 | // The request goes out before the actions are known, so only seed the |
| 116 | // feed list key `useFeeds` ends up reading. |
| 117 | const settledVariables = getFeedListVariables({ |
| 118 | feedChipsVariant: feedChipsVariantRef.current, |
| 119 | isOnboardingComplete: isOnboardingCompleteFromActions( |
| 120 | user, |
| 121 | data.actions, |
| 122 | ), |
| 123 | isTagChipFeedsSeeded: !!user?.flags?.tagChipFeedsSeededAt, |
| 124 | }); |
| 125 |
nothing calls this directly
no test coverage detected