Page MenuHomePhabricator

D13737.id.diff
No OneTemporary

D13737.id.diff

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

Mime Type
text/plain
Expires
Mon, Dec 23, 10:23 PM (16 h, 32 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2696875
Default Alt Text
D13737.id.diff (2 KB)

Event Timeline