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 @@ -13,7 +13,6 @@ import { relationshipActions } from '../types/relationship-types.js'; import { useCurrentUserFID, - useUnlinkFID, useSetLocalFID, useSetLocalCurrentUserSupportsDCs, } from '../utils/farcaster-utils.js'; @@ -56,8 +55,6 @@ const fid = useCurrentUserFID(); - const unlinkFID = useUnlinkFID(); - const prevCanQueryRef = React.useRef(); // It's possible for the user to log out while handleFarcasterMutuals below @@ -170,7 +167,7 @@ } prevCanQueryHandleCurrentUserFIDRef.current = canQueryHandleCurrentUserFID; - if (!canQueryHandleCurrentUserFID || !currentUserID || !neynarClient) { + if (!canQueryHandleCurrentUserFID || !currentUserID) { return; } @@ -178,27 +175,14 @@ currentUserID, ]); const identityFID = userIdentities[currentUserID]?.farcasterID; - const identityFIDRequestTimedOut = identityFID - ? false - : getCachedUserIdentity(currentUserID) === undefined; + const identityFIDRequestTimedOut = + !identityFID && getCachedUserIdentity(currentUserID) === undefined; if (userIdentities[currentUserID]) { setLocalDCsSupport(userIdentities[currentUserID].hasFarcasterDCsToken); } - if (fid && !identityFIDRequestTimedOut && fid !== identityFID) { - setLocalFID(identityFID); - return; - } else if (fid) { - const isCurrentUserFIDValid = - await neynarClient.checkIfCurrentUserFIDIsValid(fid); - if (!isCurrentUserFIDValid) { - await unlinkFID(); - return; - } - } - - if (identityFID) { + if (fid !== identityFID && !identityFIDRequestTimedOut) { setLocalFID(identityFID); } @@ -207,9 +191,7 @@ canQueryHandleCurrentUserFID, findUserIdentities, currentUserID, - neynarClient, fid, - unlinkFID, setLocalFID, getCachedUserIdentity, setLocalDCsSupport, diff --git a/lib/utils/neynar-client.js b/lib/utils/neynar-client.js --- a/lib/utils/neynar-client.js +++ b/lib/utils/neynar-client.js @@ -313,28 +313,6 @@ return farcasterChannels; } - async checkIfCurrentUserFIDIsValid(fid: string): Promise { - const url = getNeynarURL('2', 'user/bulk', { fids: fid }); - - try { - const response = await fetch(url, { - method: 'GET', - headers: { - Accept: 'application/json', - api_key: this.apiKey, - }, - }); - - return response.ok; - } catch (error) { - console.log( - 'Failed to check if current user FID is valid:', - getMessageForException(error) ?? 'unknown', - ); - throw error; - } - } - async fetchFarcasterCastByHash(hash: string): Promise { const url = getNeynarURL('2', 'cast', { identifier: hash, type: 'hash' }); diff --git a/native/components/connect-farcaster-bottom-sheet.react.js b/native/components/connect-farcaster-bottom-sheet.react.js --- a/native/components/connect-farcaster-bottom-sheet.react.js +++ b/native/components/connect-farcaster-bottom-sheet.react.js @@ -81,19 +81,19 @@ const isAppForegrounded = useIsAppForegrounded(); React.useEffect(() => { - if (fid && isAppForegrounded) { - if (currentUserSupportsDCs || !supportsFarcasterDCs) { - goBack(); - } else if (supportsFarcasterDCs && !showConnectDCs) { - setShowConnectDCs(true); - } + if (!fid || !isAppForegrounded) { + return; + } + if (currentUserSupportsDCs || !supportsFarcasterDCs) { + goBack(); + return; } + setShowConnectDCs(true); }, [ fid, goBack, isAppForegrounded, currentUserSupportsDCs, - showConnectDCs, supportsFarcasterDCs, ]);