(props: Props)
| 24 | }; |
| 25 | |
| 26 | function FarcasterDataHandler(props: Props): React.Node { |
| 27 | const { children } = props; |
| 28 | |
| 29 | const isActive = useSelector(state => state.lifecycleState !== 'background'); |
| 30 | |
| 31 | const currentUserID = useSelector(state => state.currentUserInfo?.id); |
| 32 | |
| 33 | const loggedIn = useIsLoggedInToIdentityAndAuthoritativeKeyserver(); |
| 34 | |
| 35 | const neynarClient = React.useContext(NeynarClientContext)?.client; |
| 36 | |
| 37 | const identityServiceClient = React.useContext(IdentityClientContext); |
| 38 | const getFarcasterUsers = |
| 39 | identityServiceClient?.identityClient.getFarcasterUsers; |
| 40 | |
| 41 | const { getCachedUserIdentity, getUserIdentities: findUserIdentities } = |
| 42 | useUserIdentityCache(); |
| 43 | |
| 44 | const dispatch = useDispatch(); |
| 45 | const dispatchActionPromise = useDispatchActionPromise(); |
| 46 | |
| 47 | const updateRelationships = useUpdateRelationships(); |
| 48 | const createThreadsAndRobotextForFarcasterMutuals = React.useCallback( |
| 49 | async (userIDs: $ReadOnlyArray<string>) => { |
| 50 | for (const userID of userIDs) { |
| 51 | await dispatchActionPromise( |
| 52 | updateRelationshipsActionTypes, |
| 53 | updateRelationships(relationshipActions.FARCASTER_MUTUAL, [userID]), |
| 54 | ); |
| 55 | } |
| 56 | }, |
| 57 | [dispatchActionPromise, updateRelationships], |
| 58 | ); |
| 59 | |
| 60 | const userInfos = useSelector(state => state.userStore.userInfos); |
| 61 | |
| 62 | const fid = useCurrentUserFID(); |
| 63 | |
| 64 | const prevCanQueryRef = React.useRef<?boolean>(); |
| 65 | |
| 66 | // It's possible for the user to log out while handleFarcasterMutuals below |
| 67 | // is running. It's not a big deal, but this can lead to a useless server call |
| 68 | // at the end. To avoid that useless server call, we want to check whether the |
| 69 | // user is logged in beforehand, but the value of loggedIn bound in the |
| 70 | // callback will be outdated. Instead, we can check this ref, which will be |
| 71 | // updated on every render. |
| 72 | const loggedInRef = React.useRef(loggedIn); |
| 73 | loggedInRef.current = loggedIn; |
| 74 | |
| 75 | const deviceKind = useDeviceKind(); |
| 76 | |
| 77 | const handleFarcasterMutualsIsRunningRef = React.useRef(false); |
| 78 | const handleFarcasterMutuals = React.useCallback(async () => { |
| 79 | if (deviceKind !== 'primary') { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | const canQuery = isActive && !!fid && loggedIn; |
nothing calls this directly
no test coverage detected