diff --git a/lib/components/farcaster-data-handler.react.js b/lib/components/farcaster-data-handler.react.js --- a/lib/components/farcaster-data-handler.react.js +++ b/lib/components/farcaster-data-handler.react.js @@ -2,6 +2,10 @@ import * as React from 'react'; +import { + setAuxUserFIDsActionType, + clearAuxUserFIDsActionType, +} from '../actions/aux-user-actions.js'; import { updateRelationships as serverUpdateRelationships, updateRelationshipsActionTypes, @@ -14,7 +18,7 @@ import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js'; import { useCurrentUserFID } from '../utils/farcaster-utils.js'; import { useDispatchActionPromise } from '../utils/redux-promise-utils.js'; -import { useSelector } from '../utils/redux-utils.js'; +import { useSelector, useDispatch } from '../utils/redux-utils.js'; import { usingCommServicesAccessToken } from '../utils/services-utils.js'; function FarcasterDataHandler(): React.Node { @@ -30,7 +34,10 @@ const identityServiceClient = React.useContext(IdentityClientContext); const getFarcasterUsers = identityServiceClient?.identityClient.getFarcasterUsers; + const findUserIdentities = + identityServiceClient?.identityClient.findUserIdentities; + const dispatch = useDispatch(); const dispatchActionPromise = useDispatchActionPromise(); const updateRelationships = useLegacyAshoatKeyserverCall( serverUpdateRelationships, @@ -66,6 +73,7 @@ !fid || !neynarClient || !getFarcasterUsers || + !findUserIdentities || !currentUserID ) { return; @@ -99,6 +107,30 @@ userIDsToFIDIncludingCurrentUser, ), ); + const userStoreIDs = Object.keys(userInfos); + + const userIdentities = await findUserIdentities(userStoreIDs); + + const userStoreFarcasterUsers = Object.entries(userIdentities) + .filter(([, identity]) => identity.farcasterId !== null) + .map(([userID, identity]) => { + return { + userID, + username: identity.username, + farcasterID: identity.farcasterId, + }; + }); + + dispatch({ + type: clearAuxUserFIDsActionType, + }); + + dispatch({ + type: setAuxUserFIDsActionType, + payload: { + farcasterUsers: userStoreFarcasterUsers, + }, + }); })(); }, [ isActive, @@ -108,6 +140,8 @@ getFarcasterUsers, userInfos, dispatchActionPromise, + dispatch, + findUserIdentities, createThreadsAndRobotextForFarcasterMutuals, currentUserID, ]);