Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3358681
D11606.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11606.diff
View Options
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
@@ -8,7 +8,6 @@
} from '../actions/relationship-actions.js';
import { NeynarClientContext } from '../components/neynar-client-provider.react.js';
import { cookieSelector } from '../selectors/keyserver-selectors.js';
-import { isLoggedIn } from '../selectors/user-selectors.js';
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { relationshipActions } from '../types/relationship-types.js';
import { useLegacyAshoatKeyserverCall } from '../utils/action-utils.js';
@@ -21,10 +20,10 @@
function FarcasterDataHandler(): React.Node {
const isActive = useSelector(state => state.lifecycleState !== 'background');
- const hasCurrentUserInfo = useSelector(isLoggedIn);
const cookie = useSelector(cookieSelector(authoritativeKeyserverID()));
const hasUserCookie = !!(cookie && cookie.startsWith('user='));
- const loggedIn = hasCurrentUserInfo && hasUserCookie;
+ const currentUserID = useSelector(state => state.currentUserInfo?.id);
+ const loggedIn = !!currentUserID && hasUserCookie;
const neynarClient = React.useContext(NeynarClientContext)?.client;
@@ -37,10 +36,10 @@
serverUpdateRelationships,
);
const createThreadsAndRobotextForFarcasterMutuals = React.useCallback(
- (userIDs: $ReadOnlyArray<string>) =>
+ (userIDsToFID: { +[userID: string]: string }) =>
updateRelationships({
action: relationshipActions.FARCASTER_MUTUAL,
- userIDs,
+ userIDsToFID,
}),
[updateRelationships],
);
@@ -61,7 +60,14 @@
}
prevCanQueryRef.current = canQuery;
- if (!loggedIn || !isActive || !fid || !neynarClient || !getFarcasterUsers) {
+ if (
+ !loggedIn ||
+ !isActive ||
+ !fid ||
+ !neynarClient ||
+ !getFarcasterUsers ||
+ !currentUserID
+ ) {
return;
}
@@ -70,16 +76,28 @@
const commFCUsers = await getFarcasterUsers(followerFIDs);
- const commUserIDs = commFCUsers.map(({ userID }) => userID);
+ const newCommUsers = commFCUsers.filter(
+ ({ userID }) => !userInfos[userID],
+ );
- const newCommUserIDs = commUserIDs.filter(userID => !userInfos[userID]);
- if (newCommUserIDs.length === 0) {
+ if (newCommUsers.length === 0) {
return;
}
+ const userIDsToFID: { +[userID: string]: string } = Object.fromEntries(
+ newCommUsers.map(({ userID, farcasterID }) => [userID, farcasterID]),
+ );
+
+ const userIDsToFIDIncludingCurrentUser: { +[userID: string]: string } = {
+ ...userIDsToFID,
+ [(currentUserID: string)]: fid,
+ };
+
void dispatchActionPromise(
updateRelationshipsActionTypes,
- createThreadsAndRobotextForFarcasterMutuals(newCommUserIDs),
+ createThreadsAndRobotextForFarcasterMutuals(
+ userIDsToFIDIncludingCurrentUser,
+ ),
);
})();
}, [
@@ -91,6 +109,7 @@
userInfos,
dispatchActionPromise,
createThreadsAndRobotextForFarcasterMutuals,
+ currentUserID,
]);
return null;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 5:46 AM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578565
Default Alt Text
D11606.diff (3 KB)
Attached To
Mode
D11606: [lib] Update `FarcasterDataHandler` to construct `FarcasterRelationshipRequest` with `userIDsToFID`
Attached
Detach File
Event Timeline
Log In to Comment