Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3519547
D13737.id45264.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13737.id45264.diff
View Options
diff --git a/lib/components/user-identity-cache.react.js b/lib/components/user-identity-cache.react.js
--- a/lib/components/user-identity-cache.react.js
+++ b/lib/components/user-identity-cache.react.js
@@ -51,6 +51,7 @@
userIDs: $ReadOnlyArray<string>,
) => Promise<UserIdentitiesResponse>,
+getCachedUserIdentity: (userID: string) => ?UserIdentityResult,
+ +invalidateCacheForUser: (userID: string) => void,
};
type UserIdentityResult =
@@ -225,12 +226,18 @@
[getCachedUserIdentityEntry, findUserIdentities],
);
+ const invalidateCacheForUser = React.useCallback((userID: string) => {
+ const cache = userIdentityCacheRef.current;
+ cache.delete(userID);
+ }, []);
+
const value = React.useMemo(
() => ({
getUserIdentities,
getCachedUserIdentity,
+ invalidateCacheForUser,
}),
- [getUserIdentities, getCachedUserIdentity],
+ [getUserIdentities, getCachedUserIdentity, invalidateCacheForUser],
);
return (
diff --git a/lib/utils/farcaster-utils.js b/lib/utils/farcaster-utils.js
--- a/lib/utils/farcaster-utils.js
+++ b/lib/utils/farcaster-utils.js
@@ -4,6 +4,7 @@
import * as React from 'react';
import { setSyncedMetadataEntryActionType } from '../actions/synced-metadata-actions.js';
+import { useUserIdentityCache } from '../components/user-identity-cache.react.js';
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { syncedMetadataNames } from '../types/synced-metadata-types.js';
import { useSelector, useDispatch } from '../utils/redux-utils.js';
@@ -32,6 +33,8 @@
function useSetLocalFID(): (fid: ?string) => void {
const dispatch = useDispatch();
+ const { invalidateCacheForUser } = useUserIdentityCache();
+ const currentUserID = useSelector(state => state.currentUserInfo?.id);
return React.useCallback(
(fid: ?string) => {
// If we're unsetting the FID, we should set it to NO_FID_METADATA to
@@ -44,8 +47,11 @@
data: fidToSet,
},
});
+ if (currentUserID) {
+ invalidateCacheForUser(currentUserID);
+ }
},
- [dispatch],
+ [dispatch, currentUserID, invalidateCacheForUser],
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 10:23 PM (16 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2696875
Default Alt Text
D13737.id45264.diff (2 KB)
Attached To
Mode
D13737: [lib] Invalidate UserIdentityCache when changing FID
Attached
Detach File
Event Timeline
Log In to Comment