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 @@ -7,11 +7,13 @@ updateRelationships as serverUpdateRelationships, updateRelationshipsActionTypes, } from '../actions/relationship-actions.js'; +import { setSyncedMetadataEntryActionType } from '../actions/synced-metadata-actions.js'; import { NeynarClientContext } from '../components/neynar-client-provider.react.js'; import { useLegacyAshoatKeyserverCall } from '../keyserver-conn/legacy-keyserver-call.js'; import { cookieSelector } from '../selectors/keyserver-selectors.js'; import { IdentityClientContext } from '../shared/identity-client-context.js'; import { relationshipActions } from '../types/relationship-types.js'; +import { syncedMetadataNames } from '../types/synced-metadata-types.js'; import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js'; import { useCurrentUserFID } from '../utils/farcaster-utils.js'; import { useDispatchActionPromise } from '../utils/redux-promise-utils.js'; @@ -134,6 +136,31 @@ }); }, [loggedIn, isActive, findUserIdentities, userInfos, dispatch]); + const handleCurrentUserFID = React.useCallback(async () => { + if ( + !loggedIn || + !isActive || + !findUserIdentities || + !currentUserID || + fid + ) { + return; + } + + const currentUserIdentityObj = await findUserIdentities([currentUserID]); + const identityFID = currentUserIdentityObj[currentUserID].farcasterID; + + if (identityFID) { + dispatch({ + type: setSyncedMetadataEntryActionType, + payload: { + name: syncedMetadataNames.CURRENT_USER_FID, + data: identityFID, + }, + }); + } + }, [loggedIn, isActive, findUserIdentities, currentUserID, fid, dispatch]); + React.useEffect(() => { if (!usingCommServicesAccessToken) { return; @@ -141,7 +168,8 @@ void handleFarcasterMutuals(); void handleUserStoreFIDs(); - }, [handleFarcasterMutuals, handleUserStoreFIDs]); + void handleCurrentUserFID(); + }, [handleCurrentUserFID, handleFarcasterMutuals, handleUserStoreFIDs]); return null; } diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -15,6 +15,7 @@ } from 'lib/actions/entry-actions.js'; import { ChatMentionContextProvider } from 'lib/components/chat-mention-provider.react.js'; import { EditUserAvatarProvider } from 'lib/components/edit-user-avatar-provider.react.js'; +import { FarcasterDataHandler } from 'lib/components/farcaster-data-handler.react.js'; import { ModalProvider, useModalContext, @@ -250,6 +251,7 @@ + {content}